From db76e31101574efd69ca734c5a39cff3bab23923 Mon Sep 17 00:00:00 2001 From: Alexandra Capatina <46926675+alexandra-c@users.noreply.github.com> Date: Wed, 12 Oct 2022 14:36:57 +0300 Subject: [PATCH] Remove applyMiddleware when not choosing withRights option --- generators/app/templates/infrastructure/package.json | 2 +- .../templates/infrastructure/src/startup/schema.js | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/generators/app/templates/infrastructure/package.json b/generators/app/templates/infrastructure/package.json index b514a66..5a40182 100644 --- a/generators/app/templates/infrastructure/package.json +++ b/generators/app/templates/infrastructure/package.json @@ -83,7 +83,6 @@ "console-stamp": "^3.0.6", "dotenv": "16.0.1", "graphql": "15.8.0", - "graphql-middleware": "^6.1.33", <%_ if(addSubscriptions){ _%> "apollo-server-core": "^3.10.0", "graphql-redis-subscriptions": "^2.5.0", @@ -93,6 +92,7 @@ "ws": "^8.8.0", <%_}_%> <%_ if(withRights){ _%> + "graphql-middleware": "^6.1.33", "graphql-shield": "^7.5.0", <%_}_%> "graphql-upload": "^13.0.0", diff --git a/generators/app/templates/infrastructure/src/startup/schema.js b/generators/app/templates/infrastructure/src/startup/schema.js index 93e2d8f..17ebc9c 100644 --- a/generators/app/templates/infrastructure/src/startup/schema.js +++ b/generators/app/templates/infrastructure/src/startup/schema.js @@ -7,12 +7,9 @@ const { loadTypedefsSync } = require('@graphql-tools/load'), { GraphQLFileLoader } = require('@graphql-tools/graphql-file-loader'), { join } = require('path') -<%_ if(withRights || (dataLayer === "prisma" && withMultiTenancy)){ _%> -const { applyMiddleware } = require('graphql-middleware') -<%_}_%> - <%_ if(withRights){ _%> -const { permissionsMiddleware } = require('../middleware/permissions/index') +const { applyMiddleware } = require('graphql-middleware'), + { permissionsMiddleware } = require('../middleware/permissions/index') <%_}_%> @@ -22,8 +19,8 @@ const sources = loadTypedefsSync(join(__dirname, '../**/*.graphql'), { const typeDefs = sources.map(source => source.document) const resolvers = mergeResolvers(loadFilesSync(join(__dirname, '../**/resolvers.{js,ts}'))) -<%_ if(withRights || (dataLayer === "prisma" && withMultiTenancy)){ _%> -module.exports = applyMiddleware(makeExecutableSchema({ typeDefs, resolvers })<% if(withRights){ %>, permissionsMiddleware<%}%>); +<%_ if(withRights){ _%> +module.exports = applyMiddleware(makeExecutableSchema({ typeDefs, resolvers }), permissionsMiddleware) <%_} else { _%> module.exports = makeExecutableSchema({ typeDefs, resolvers }); <%_}_%>