From 04476e32a6cec74ff697914b1e81fa13e4c55b7a Mon Sep 17 00:00:00 2001 From: Alexandre Bodin Date: Mon, 10 Feb 2020 11:57:06 +0100 Subject: [PATCH] Cleanup graphql Signed-off-by: Alexandre Bodin --- .../api/homepage/config/schema.graphql.js | 38 ------------------- .../strapi-plugin-graphql/services/Schema.js | 18 +++------ 2 files changed, 6 insertions(+), 50 deletions(-) delete mode 100644 examples/getstarted/api/homepage/config/schema.graphql.js diff --git a/examples/getstarted/api/homepage/config/schema.graphql.js b/examples/getstarted/api/homepage/config/schema.graphql.js deleted file mode 100644 index 5f82ca4b67..0000000000 --- a/examples/getstarted/api/homepage/config/schema.graphql.js +++ /dev/null @@ -1,38 +0,0 @@ -module.exports = { - query: ` - - customQuery: String - customQuery2: String - restaurantByAddress: Homepage - q1: Homepage - - `, - resolver: { - Query: { - customQuery: { - policies: [], // consider that the local policies are in the api which is created this file - resolverOf: 'application::restaurant.restaurant.find', - resolver() {}, - }, - customQuery2: { - policies: [], // consider that the local policies are in the api which is created this file - resolver: 'application::restaurant.restaurant.find', - }, - restaurantByAddress: { - policies: [], // consider that the local policies are in the api which is created this file - resolverOf: 'application::address.address.find', - resolver: 'application::homepage.homepage.find', - }, - q1: { - policies: ['test'], - resolverOf: 'application::restaurant.restaurant.find', - resolver(root, args, ctx) { - return { - id: 1, - title: 'coucou', - }; - }, - }, - }, - }, -}; diff --git a/packages/strapi-plugin-graphql/services/Schema.js b/packages/strapi-plugin-graphql/services/Schema.js index 78eb77dacb..01ff5c4c3a 100644 --- a/packages/strapi-plugin-graphql/services/Schema.js +++ b/packages/strapi-plugin-graphql/services/Schema.js @@ -160,19 +160,13 @@ const generateSchema = () => { return {}; } - const queryFields = formatGQL( - shadowCRUD.query, - resolver.Query, - null, - 'query' - ); + const queryFields = + shadowCRUD.query && + formatGQL(shadowCRUD.query, resolver.Query, null, 'query'); - const mutationFields = formatGQL( - shadowCRUD.mutation, - resolver.Mutation, - null, - 'mutation' - ); + const mutationFields = + shadowCRUD.mutation && + formatGQL(shadowCRUD.mutation, resolver.Mutation, null, 'mutation'); const scalars = Types.getScalars();