Skip to content

Detail HTTP status codes to use for various error conditions #354

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

benjie
Copy link
Member

@benjie benjie commented Jun 26, 2025

We should embrace HTTP semantics as much as possible. Previously I over-specified the status codes to make it seem like 400 should be used for everything when actually you should use the appropriate status code for the situation. I've attempted to address this by being much more explicit, and have split the previous examples into 400 (syntactically invalid request) and 422 (syntactically valid request, but semantically unprocessable) whilst also putting recommendations for various other HTTP status codes you should consider using inspired by various situations you're likely to see as a GraphQL server. I've tried to define them mostly in a sort of "chronological" order of the way that you would process a request.

@benjie
Copy link
Member Author

benjie commented Jun 26, 2025

Note: the original name for 422 was "Unprocessable Entity", but it's more commonly know as "Unprocessable Content" these days. The text itself is unimportant, so unimportant HTTP2+ doesn't even include it in the response any more IIRC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should we use/encourage HTTP 422 for validation failures?
1 participant