enonic / lib-guillotine

Apache License 2.0
3 stars 0 forks source link

Add `queryContext` to arguments for `execute` function #195

Closed anatol-sialitski closed 2 years ago

anatol-sialitski commented 2 years ago

Query context argument should be added tot execute function. It allows to developers provide shared data between fields.

This context will be available from env.context variable

For instance:

let params = {
        сontext: {
            myParameter: 'anyvalue' 
        },
        schemaOptions: {
            creationCallbacks: {
                'portal_Site': function (context, params) {
                    params.fields._path = {
                        type: graphqlLib.nonNull(graphqlLib.GraphQLString),
                        resolve: function (env) {
                            return env.source._path + '/ ' + env.context.myParameter;
                        }
                    }
                }
            }
        }
    };

then

guillotineLib.execute(params)