mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 19:04:38 +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: {
|
defaults: {
|
||||||
prefix: '',
|
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
|
// Define GraphQL route to GraphQL schema
|
||||||
// or disable the global variable
|
// or disable the global variable
|
||||||
if (strapi.config.graphql.enabled === true) {
|
if (this.defaults.graphql.enabled === true) {
|
||||||
// Wait GraphQL schemas generation
|
strapi.router.get(this.defaults.graphql.route, strapi.middlewares.graphql({
|
||||||
strapi.once('orm:graphql:ready', function () {
|
schema: strapi.schemas,
|
||||||
strapi.router.get(strapi.config.graphql.route, strapi.middlewares.graphql({
|
pretty: true
|
||||||
schema: strapi.schemas,
|
}));
|
||||||
pretty: true
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
global.graphql = undefined;
|
global.graphql = undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
"auth",
|
"auth",
|
||||||
"framework",
|
"framework",
|
||||||
"grant",
|
"grant",
|
||||||
|
"graphql",
|
||||||
"koa",
|
"koa",
|
||||||
"koajs",
|
"koajs",
|
||||||
"lusca",
|
"lusca",
|
||||||
@ -41,6 +42,7 @@
|
|||||||
"koa-compose": "~2.3.0",
|
"koa-compose": "~2.3.0",
|
||||||
"koa-cors": "~0.0.16",
|
"koa-cors": "~0.0.16",
|
||||||
"koa-favicon": "~1.2.0",
|
"koa-favicon": "~1.2.0",
|
||||||
|
"koa-graphql": "^0.4.4",
|
||||||
"koa-gzip": "~0.1.0",
|
"koa-gzip": "~0.1.0",
|
||||||
"koa-i18n": "~1.2.0",
|
"koa-i18n": "~1.2.0",
|
||||||
"koa-ip": "~0.1.0",
|
"koa-ip": "~0.1.0",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user