graphql-shield
graphql-shield copied to clipboard
Created apollo-federation.mdx
I struggled using Graphql-shield with an Apollo Federation gateway. Due to my fallbackRule being set to deny, the endpoints required by Apollo Federation were blocked. Couldn't find any documentation for this issue, but I found a few unanswered questions on Stack Overflow. I would have appreciated seeing something like this earlier, so wrote this to help others with this common(?) problem
This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.
🔍 Inspect: https://vercel.com/maticzav/graphql-shield/BirALucEJN2n9adcbuLq9g4jLDJs
✅ Preview: https://graphql-shield-git-fork-namyts-patch-1-maticzav.vercel.app
I have the same problem when need to resolve values from other subgraph
how i can apply these fixes in my local project. can any one help me ?
how i can apply these fixes in my local project. can any one help me ?
https://graphql-shield-git-fork-namyts-patch-1-maticzav.vercel.app/docs/advanced/apollo-federation - This is what I wrote to be added to the documentation. If you think it could be written more clearly, feel free to make some more edits. I also gave this answer here
i have tried this solution but not working with me. ===> { export const permissions = shield({ Query: { _service: allow, }, _Service: { sdl: allow } },{ fallbackRule: deny, debug: true, allowExternalErrors: true, }); }
although i have fallbackRule: true, subgraph can't resolve value from another one
although i have fallbackRule: true, subgraph can't resolve value from another one
If you set fallbackRule to allow and it still doesn't work, the problem probably isnt with graphql-shield... The fix I've documented was to allow apollo's introspection to work. Maybe try creating a Stack Overflow question with your problem in more detail to see if someone can figure it out :)
You could also try allowing the other values I mentioned in my documentation addition, but I am thinking your problem might be unrelated since this works completely fine for me
@maticzav - Could you merge my documentation additions please?
when i remove graphql shield middleware the problem solved so it is shield problem
Man I've been struggling with this for almost one day. This library is shit. Just use graphql-middleware.
Man I've been struggling with this for almost one day. This library is shit. Just use graphql-middleware.
I've switched to @graphql-authz since this post was made. Similar logic is required to allow the endpoints, but works fine for me...
i have solved the problem and all is worked fine with me