Consider new configuration for dedicated GraphQL object

This commit is contained in:
Aurélien Georget 2015-10-20 12:13:43 +02:00
parent 92a1d0d516
commit 75f11a7d0b
3 changed files with 10 additions and 8 deletions

View File

@ -23,7 +23,11 @@ module.exports = function (strapi) {
defaults: {
prefix: '',
routes: {}
routes: {},
graphql: {
enabled: true,
route: '/graphql'
}
},
/**
@ -84,12 +88,10 @@ module.exports = function (strapi) {
strapi.log.warn('Ignored attempt to bind route `' + endpoint + '` to unknown controller/action.');
}
});
if (strapi.config.globals.graphql === true || _.isPlainObject(strapi.config.globals.graphql)) {
const GraphQLPath = _.isBoolean(strapi.config.globals.graphql) ? '/graphql' : strapi.config.globals.graphql.path;
if (strapi.config.graphql.enabled === true) {
// Define GraphQL route with modified Waterline models to GraphQL schema
strapi.router.get(GraphQLPath, strapi.middlewares.graphql({
strapi.router.get(strapi.config.graphql.route, strapi.middlewares.graphql({
schema: strapi.schemas,
pretty: true
}));

View File

@ -180,7 +180,7 @@ module.exports = function (strapi) {
});
});
if (strapi.config.globals.graphql === true) {
if (strapi.config.graphql.enabled === true) {
// Parse each models and add associations array
_.forEach(strapi.orm.collections, function(collection, key) {
if (strapi.models.hasOwnProperty(key)) {

View File

@ -77,7 +77,7 @@
"strapi-generate-users": "^1.1.0",
"unzip2": "^0.2.5",
"waterline": "^0.10.26",
"waterline-to-graphql": "0.0.2",
"waterline-graphql": "0.0.1",
"winston": "^1.1.0"
},
"devDependencies": {