Propagating authentication errors through GraphQL gateway #6166
Unanswered
wujekbogdan
asked this question in
Q&A
Replies: 1 comment 1 reply
-
In subschema execution, we are not able to know how HTTP status codes are used by the service. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a GraphQL gateway that redirects requests to the main GraphQL server. I use the following executor to pass the original request's authorization header to the main GraphQL server.
Then I use that schema to instantiate the Yoga server.
It all works fine, but authentication errors do not propagate through the Yoga server. If the original GraphQL server returns a
401
error, the Yoga server returns200
and an error message such as:Disabling error masking doesn't help. It only affects regular requests, e.g., when the original server responds with a validation error.
Is there any way to force the HTTP executor to propagate all HTTP errors?
The only solution (or rather workaround) I found is providing a custom fetch implementation that throws an error depending on the
response.status
:But It doesn't seem elegant. I feel this should happen at the HTTP executor level rather than within the
fetch
implementation. It would be better if original errors propagated seamlessly instead of being explicitly handled based on error codes."Beta Was this translation helpful? Give feedback.
All reactions