mirror of
https://github.com/strapi/strapi.git
synced 2025-07-30 12:29:30 +00:00
Improve GraphQL errors when there are no collections
This commit is contained in:
parent
b3f4bc5b96
commit
e0834065f7
@ -42,8 +42,14 @@ module.exports = function (strapi) {
|
|||||||
// Define GraphQL route to GraphQL schema
|
// Define GraphQL route to GraphQL schema
|
||||||
if (this.defaults.graphql.enabled === true) {
|
if (this.defaults.graphql.enabled === true) {
|
||||||
require('./schema').getGraphQLSchema(_.assign({
|
require('./schema').getGraphQLSchema(_.assign({
|
||||||
collections: strapi.bookshelf.collections
|
collections: strapi.bookshelf.collections || {}
|
||||||
}, strapi.config.graphql), function (schemas) {
|
}, strapi.config.graphql), function (err, schemas) {
|
||||||
|
if (err) {
|
||||||
|
strapi.log.warn(err);
|
||||||
|
console.log();
|
||||||
|
|
||||||
|
return cb();
|
||||||
|
}
|
||||||
|
|
||||||
// Mount GraphQL server
|
// Mount GraphQL server
|
||||||
strapi.app.use(strapi.middlewares.mount(self.defaults.graphql.route, strapi.middlewares.graphql((request, context) => ({
|
strapi.app.use(strapi.middlewares.mount(self.defaults.graphql.route, strapi.middlewares.graphql((request, context) => ({
|
||||||
|
@ -38,7 +38,7 @@ module.exports = {
|
|||||||
|
|
||||||
getGraphQLSchema: function (params, cb) {
|
getGraphQLSchema: function (params, cb) {
|
||||||
if (_.isEmpty(params.collections)) {
|
if (_.isEmpty(params.collections)) {
|
||||||
return 'Error: Empty object collections';
|
return cb('GraphQL server has not been started because there are no models', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set defaults properties
|
// Set defaults properties
|
||||||
@ -53,7 +53,7 @@ module.exports = {
|
|||||||
}, _.isNull));
|
}, _.isNull));
|
||||||
|
|
||||||
// Return schema
|
// Return schema
|
||||||
cb(Schema);
|
cb(null, Schema);
|
||||||
|
|
||||||
// Build policies
|
// Build policies
|
||||||
this.buildPolicies();
|
this.buildPolicies();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user