enonic / lib-guillotine

Apache License 2.0
3 stars 0 forks source link

Add the ability to extend interfaces during schema creation #210

Closed anatol-sialitski closed 2 years ago

anatol-sialitski commented 2 years ago

Current implementation does not allow to modify interface types during schema creation how it to do for an object type.

It will be great if we able to specify interfaces in creationCallbacks too.

Example of usage:

const guillotineLib = require("/lib/guillotine");
const graphQlLib = require("/lib/graphql");

exports.post = function (req) {
    let input = JSON.parse(req.body);

    let params = {
        query: input.query,
        variables: input.variables,
        schemaOptions: {
            creationCallbacks: {
                'Content': function(context, params) { // Content is an interface
                    params.fields.testField = {
                        type: graphQlLib.GraphQLString,
                        resolve: function (env) {
                            return "testValue";
                        }
                    };
                }
            }
        }
    };

    return {
        contentType: 'application/json',
        headers: CORS_HEADERS,
        body: guillotineLib.execute(params)
    };
};