Following the guide here::
I have managed to successfully extend my GraphQL schema inside the register
function at /src/index.js
.
Currently the schema has grown a little out of hand so I’ve decided I want to move things around to clean it up. I’d like to register the extension to grapgql in /src/extensions/graphql
but I’ve run into a small problem. The graphql
plugin object(shown below) passed to the strapi-server.js
file graphql.services.extension
is a function(which does return an object containing use
but I’ve tried calling it and then calling use()
and it doesn’t seem to work.) and calling strapi.plugin(‘graphql’) returns undefined
. I suppose at this point in the startup of the app(before register
is called) the plugin/strapi hasn’t been fully bootstrapped and that’s why it’s unavailable.
Question: How can I register an extension to the graphql schema from /src/extensions/graphql/strapi-server
?
GraphQL Plugin **in strapi-server.js** function export
GRAPHQL PLUGIN {
config: {
...
},
bootstrap: [AsyncFunction (anonymous)],
services: {
builders: [Function (anonymous)],
'content-api': [Function (anonymous)],
constants: [Function (anonymous)],
extension: [Function: createExtension],
format: [Function (anonymous)],
internals: [Function (anonymous)],
'type-registry': [Function (anonymous)],
utils: [Function (anonymous)]
},
destroy: [Function: destroy],
register: [Function: register],
routes: [],
controllers: {},
policies: {},
middlewares: {},
contentTypes: {}
}