mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 01:47:13 +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
 | ||||
|       if (this.defaults.graphql.enabled === true) { | ||||
|         require('./schema').getGraphQLSchema(_.assign({ | ||||
|           collections: strapi.bookshelf.collections | ||||
|         }, strapi.config.graphql), function (schemas) { | ||||
|           collections: strapi.bookshelf.collections || {} | ||||
|         }, strapi.config.graphql), function (err, schemas) { | ||||
|           if (err) { | ||||
|             strapi.log.warn(err); | ||||
|             console.log(); | ||||
| 
 | ||||
|             return cb(); | ||||
|           } | ||||
| 
 | ||||
|           // Mount GraphQL server
 | ||||
|           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) { | ||||
|     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
 | ||||
| @ -53,7 +53,7 @@ module.exports = { | ||||
|     }, _.isNull)); | ||||
| 
 | ||||
|     // Return schema
 | ||||
|     cb(Schema); | ||||
|     cb(null, Schema); | ||||
| 
 | ||||
|     // Build policies
 | ||||
|     this.buildPolicies(); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Aurélien Georget
						Aurélien Georget