Improve errors when subgraph service returns a non-2xx status code#2118
Merged
bnjjj merged 8 commits intoapollographql:devfrom Nov 21, 2022
Merged
Conversation
o0Ignition0o
approved these changes
Nov 16, 2022
Contributor
o0Ignition0o
left a comment
There was a problem hiding this comment.
This looks really great! 🎉
NEXT_CHANGELOG.md
Outdated
|
|
||
| By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/2096 | ||
|
|
||
| ### Improve errors when subgraph returns non-2xx status code ([Issue #2117](https://github.com/apollographql/router/issues/2117)) |
Contributor
There was a problem hiding this comment.
Can we convey this will only happen with non graphql subgraph responses ?
bnjjj
reviewed
Nov 16, 2022
|
|
||
| let make_svc = make_service_fn(|_conn| async { Ok::<_, Infallible>(service_fn(handle)) }); | ||
| let server = Server::bind(&socket_addr).serve(make_svc); | ||
| if let Err(e) = server.await { |
Contributor
There was a problem hiding this comment.
Could we panic instead ? If it's for a test it's better to directly panic
Contributor
Author
There was a problem hiding this comment.
I just copied the precedence set in the other emulate_* functions.
This is my first time writing any Rust code so I'll leave this judgement call up to you.
Contributor
There was a problem hiding this comment.
Yes I know it's our mistake, we should change the other ones. We will... one day :)
bnjjj
reviewed
Nov 16, 2022
Comment on lines
407
to
409
| if let Err(e) = server.await { | ||
| eprintln!("server error: {}", e); | ||
| } |
Contributor
There was a problem hiding this comment.
Suggested change
| if let Err(e) = server.await { | |
| eprintln!("server error: {}", e); | |
| } | |
| server.await.unwrap() |
cc @col
bnjjj
approved these changes
Nov 21, 2022
garypen
pushed a commit
that referenced
this pull request
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.Closes #2117