maticzav / graphql-shield

πŸ›‘ A GraphQL tool to ease the creation of permission layer.

Home Page:https://graphql-shield.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using GraphQL Shield with GraphQLSchema object not working

alyatwa opened this issue Β· comments

I'm trying to use GraphQLSchema object with shield but it does't work
here is an example
https://repl.it/@alyatwa/shield

Hey @alyatwa πŸ‘‹,

Thank you for opening an issue. We will get back to you as soon as we can. Also, check out our Open Collective and consider contributing financially.

https://opencollective.com/graphql-shield

PS.: We offer priority support for all financial contributors. Don't forget to add priority label once you start contributing πŸ˜„

Hey @alyatwa πŸ‘‹ ,

Thank you for opening this issue. After some investigation, it seems like this is a bug in graphql-middleware. Instead of setting up the server with schema returned from applyMiddleware pass in the original schema and apply middleware as an effect

applyMiddleware(schema, permissions);

server.use(
  "/graphql",
  graphqlHTTP((request, response, graphQLParams) => ({
    schema,
    // schemaPermission,
    graphiql: true
  }))
);

Let me know if that worked for you as well. πŸ™‚

It works now!