mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 10:23:34 +00:00
Add koa-graphql && fix orm load with GraphQL server
This commit is contained in:
parent
f5a72e1198
commit
c89bad4949
@ -27,7 +27,11 @@ module.exports = function (strapi) {
|
||||
|
||||
defaults: {
|
||||
prefix: '',
|
||||
routes: {}
|
||||
routes: {},
|
||||
graphql: {
|
||||
enabled: true,
|
||||
route: '/graphql'
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -105,16 +109,16 @@ module.exports = function (strapi) {
|
||||
}
|
||||
});
|
||||
|
||||
// Override default configuration for GraphQL
|
||||
_.assign(this.defaults.graphql, strapi.config.graphql);
|
||||
|
||||
// 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
|
||||
}));
|
||||
});
|
||||
if (this.defaults.graphql.enabled === true) {
|
||||
strapi.router.get(this.defaults.graphql.route, strapi.middlewares.graphql({
|
||||
schema: strapi.schemas,
|
||||
pretty: true
|
||||
}));
|
||||
} else {
|
||||
global.graphql = undefined;
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
"auth",
|
||||
"framework",
|
||||
"grant",
|
||||
"graphql",
|
||||
"koa",
|
||||
"koajs",
|
||||
"lusca",
|
||||
@ -41,6 +42,7 @@
|
||||
"koa-compose": "~2.3.0",
|
||||
"koa-cors": "~0.0.16",
|
||||
"koa-favicon": "~1.2.0",
|
||||
"koa-graphql": "^0.4.4",
|
||||
"koa-gzip": "~0.1.0",
|
||||
"koa-i18n": "~1.2.0",
|
||||
"koa-ip": "~0.1.0",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user