graphql-shield icon indicating copy to clipboard operation
graphql-shield copied to clipboard

Created apollo-federation.mdx

Open Namyts opened this issue 2 years ago • 11 comments

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

Namyts avatar Mar 02 '22 13:03 Namyts

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

vercel[bot] avatar Mar 02 '22 13:03 vercel[bot]

I have the same problem when need to resolve values from other subgraph

elafifi avatar Mar 28 '22 20:03 elafifi

how i can apply these fixes in my local project. can any one help me ?

elafifi avatar Mar 28 '22 20:03 elafifi

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

Namyts avatar Mar 28 '22 20:03 Namyts

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

elafifi avatar Mar 28 '22 21:03 elafifi

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

Namyts avatar Mar 28 '22 21:03 Namyts

@maticzav - Could you merge my documentation additions please?

Namyts avatar Mar 28 '22 21:03 Namyts

when i remove graphql shield middleware the problem solved so it is shield problem

elafifi avatar Mar 28 '22 21:03 elafifi

Man I've been struggling with this for almost one day. This library is shit. Just use graphql-middleware.

zolero avatar Nov 16 '22 20:11 zolero

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...

Namyts avatar Nov 16 '22 20:11 Namyts

i have solved the problem and all is worked fine with me

elafifi avatar Nov 16 '22 21:11 elafifi