-
Notifications
You must be signed in to change notification settings - Fork 163
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
Status codes per GraphQL over HTTP spec #1142
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the new default is the only correct behavior. Let's deprecate this configuration, maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, users may likely have clients that count on GraphQL returning 400 even if they use application/json. The GraphQL over http spec only recommends 200 be returned, and only because (in theory) proxy services may return 400 with application/json. Users will know if their configuration meets that criteria or not, and if such a concern is warranted. And other users’ client code may always expect 200 even in the case of an error.
I think this is rather important to keep flexible, just as it was configurable in v7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The client can choose the status codes by using either
application/json
orapplication/graphql-response+json
. The additional option: usingapplication/json
and expecting 4xx codes is not forbidden but discouraged. What can force users to prefer this behavior when they can just change theAccept
header?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're assuming that they can control the clients behavior easily. In our company, we have a large infrastructure of GraphQL services that talk to each other. One client may be .NET code, one may be javascript, we even have python code. Changing the format of responses would require us to review each of these different pieces of code scattered throughout our various codebases. Any tests we've written that validate the returned status code may need to change. Since we are not exposing GraphQL to the public, compatibility with the GraphQL over HTTP protocol is not a concern. And if we had a public API, it would be important to maintain behavior of the endpoint throughout the supported version of that API. I've always had our servers return 400 for validation errors, and I expect that to continue.
It is also important to note that Apollo GraphQL server behaves as if this option were
false
by default, always returning 200 for validation errors (which are not transport errors). For compatibility with other servers alone, we may want to keep this option.I really don't see any reason this isn't a valid and normal configuration option for the server project, just like changing the default content type returned, enabling/disabling CSRF protection, or enabling/disabling form parsing. Keep in mind that it's just an option, and it's configured to the recommended default per the draft GraphQL over HTTP spec. (The spec isn't even finalized yet!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood