Skip to content

Commit

Permalink
Merge pull request #96 from osstotalsoft/small-fix
Browse files Browse the repository at this point in the history
Removed applyMiddleware and graphql-middleware package when withRights option is not selected
  • Loading branch information
alexandra-c committed Oct 12, 2022
2 parents e874ea9 + db76e31 commit 54a64a4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion generators/app/templates/infrastructure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
11 changes: 4 additions & 7 deletions generators/app/templates/infrastructure/src/startup/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
<%_}_%>


Expand All @@ -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 });
<%_}_%>
Expand Down

0 comments on commit 54a64a4

Please sign in to comment.