Graphql-shield: Apollo-server 2.0 setup

Created on 27 Oct 2018  路  6Comments  路  Source: maticzav/graphql-shield

Question about GraphQL Shield

I'm transitioning to use apollo-server instead of graphql yoga. I don't know how to implement graphql shield permisions middlewares into apollo-server 2.0, are there any examples?

I saw there was one with apollo-server-lambda but im not sure how to do it if i would use the express version.

  • [x] I have checked other questions and found none that macthes mine.

Most helpful comment

I was also in the similar situation, wanted to connect graphql-shield with apollo-server-lambda, but couldn't find a clear example.

After a few tries, I managed to connect everything via graphql-middleware. I put an example here: https://github.com/doitadrian/example-graphql-shield-apollo-server-lambda

Hope it helps 馃檪

All 6 comments

Hey @donedgardo 馃憢,

Thank you for asking such an interesting question. I would say you have two options; 1) You could wait until the PR for graphql-middleware gets merged into the Apollo-Server (apollographql/apollo-server#1799), or 2) use the workaround for applying middleware to schema. You can find more about that in the link below under the _Standalone usage_ section.

https://github.com/prisma/graphql-middleware#standalone-usage

I hope this answers your question! 馃檪

Thanks for sharing! Let me know if you need any help with anything else 馃檪.

I was also in the similar situation, wanted to connect graphql-shield with apollo-server-lambda, but couldn't find a clear example.

After a few tries, I managed to connect everything via graphql-middleware. I put an example here: https://github.com/doitadrian/example-graphql-shield-apollo-server-lambda

Hope it helps 馃檪

@doitadrian this is perfect! Would you mind if I add it to the examples section?

Sure, be my guest :) @maticzav

Was this page helpful?
0 / 5 - 0 ratings