Status code on validation fail
See original GitHub issueHello, I found such bug in returned status code when using Apollo (even in the example in this repository).
If some validation failed Apollo return status 500. I would say status code should be 400 because it is client error, not server error.
I was digging a little bit deeper. In my opinion the problem is, that you are throwing GraphQlError in error cases. But in all examples from graphql
recommended in Apollo
docs, they are calling ValidationContext.reportError(new GraphQlError(...)
instead.
I can make pull request and we can discuss it more then.
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Which status code should I use for failed validations or invalid ...
I recommend using 422 UNPROCESSABLE ENTITY for validation errors. I give a longer explanation of 4xx codes here. Share.
Read more >HTTP status codes - Oracle Help Center
HTTP status codes · 200: "OK" · 201: "Success" · 204: "Success" · 301: "Login required" · 304: "Not Modified" · 400: "There...
Read more >Which HTTP code is best suited for validation errors - Quora
HTTP Error 400 or 400 Bad Request Error is one of the HTTP Error status code which means the request was malformed or...
Read more >What http error to return in case of validation and business ...
The 403 (Forbidden) status code indicates that the server understood the request but refuses to authorize it. In this case, you might be...
Read more >HTTP Status Codes - REST API Tutorial
This class of status code indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Great catch, pushing a patch version!
#162, should introduce ability to override the error behavior.
The trade-off and how-to must be documented as well.
@PatizonP I will let you know as soon as this is done.