-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve errors when subgraph service returns a non-2xx status code #2117
Labels
Comments
Hey, thanks for opening this issue! I like the idea of adding more information on non 2XX errors if and only if the |
bnjjj
pushed a commit
that referenced
this issue
Nov 21, 2022
…2118) This PR tries to address Issue #2117 Here's an example of how the Router would now respond when a subgraph service returns a non-2xx status code and content-type not set to `application/json`. ``` { "data": null, "errors": [ { "message": "HTTP fetch failed from 'my-service': 401 Unauthorized", "path": [], "extensions": { "type": "SubrequestHttpError", "service": "my-service", "reason": "HTTP fetch failed from 'my-service': 401 Unauthorized" } } ] } ```
I think #2118 was meant to close this, but happy to re-open if that isn't the case! Thanks for the issue, and the PR! |
goto-bus-stop
pushed a commit
that referenced
this issue
Nov 29, 2022
…2118) This PR tries to address Issue #2117 Here's an example of how the Router would now respond when a subgraph service returns a non-2xx status code and content-type not set to `application/json`. ``` { "data": null, "errors": [ { "message": "HTTP fetch failed from 'my-service': 401 Unauthorized", "path": [], "extensions": { "type": "SubrequestHttpError", "service": "my-service", "reason": "HTTP fetch failed from 'my-service': 401 Unauthorized" } } ] } ```
garypen
pushed a commit
that referenced
this issue
Nov 30, 2022
…2118) This PR tries to address Issue #2117 Here's an example of how the Router would now respond when a subgraph service returns a non-2xx status code and content-type not set to `application/json`. ``` { "data": null, "errors": [ { "message": "HTTP fetch failed from 'my-service': 401 Unauthorized", "path": [], "extensions": { "type": "SubrequestHttpError", "service": "my-service", "reason": "HTTP fetch failed from 'my-service': 401 Unauthorized" } } ] } ```
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The Apollo Router handles non-2xx status codes from a subgraph service differently from the original Apollo Gateway. I would prefer this behaviour to remain consistent. I also think the current Router behaviour is insufficient as it currently ignores the status code completely and only returns an errors based on the content-type not being
application/json
.As an example, if a subgraph service returns 401 Unauthorized (content-type: text/html), the Gateway would respond with something like this:
This is useful as it provide relevant info in the error response.
However the router will currently respond with:
This is far less useful. I think the
content-type
is secondary issue to the fact that the status code was not 2xx but there is no mention of that in this error.I understand that IF a subgraph chooses to return a non-2xx status code with a content-type of
application/json
then the response body, which probably contains a custom error, should still be parsed normally.The text was updated successfully, but these errors were encountered: