mirror of
https://github.com/strapi/strapi.git
synced 2025-12-25 06:04:29 +00:00
Start GraphQL server in the router
This commit is contained in:
parent
9a32907282
commit
f5a72e1198
@ -105,6 +105,20 @@ module.exports = function (strapi) {
|
||||
}
|
||||
});
|
||||
|
||||
// Define GraphQL route to GraphQL schema
|
||||
// or disable the global variable
|
||||
if (strapi.config.graphql.enabled === true) {
|
||||
// Wait GraphQL schemas generation
|
||||
strapi.once('orm:graphql:ready', function () {
|
||||
strapi.router.get(strapi.config.graphql.route, strapi.middlewares.graphql({
|
||||
schema: strapi.schemas,
|
||||
pretty: true
|
||||
}));
|
||||
});
|
||||
} else {
|
||||
global.graphql = undefined;
|
||||
}
|
||||
|
||||
// Let the router use our routes and allowed methods.
|
||||
strapi.app.use(strapi.router.routes());
|
||||
strapi.app.use(strapi.router.allowedMethods());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user