Custom http status code response
See original GitHub issueWe are used to return different status codes depending on the error, e.g. 401, 404, 500, etc.
Is it recommended to do this in GraphQL? If so, how to do that in express-graphql
?
Thanks.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Can we create custom HTTP Status codes? - Stack Overflow
Yes you can add custom error codes. If possible use codes that already exist though, and if you are declaring ...
Read more >Customize HTTP Responses | Documentation
ServiceStack provides multiple ways to customize your services HTTP response. Each option gives you complete control of the final HTTP Response that's returned ......
Read more >List of HTTP status codes - Wikipedia
This is a list of Hypertext Transfer Protocol (HTTP) response status codes. Status codes are ... Custom error pages · List of FTP...
Read more >How to return a custom HTTP status code using WebAPI 2
This post will give you an example on how to return such a custom HTTP code. Have a look here for the natively...
Read more >Defining Custom HTTP Response Status Codes
You can define custom HTTP response codes (in addition to the standard ones defined by the <HTTP 1.1 specification in RFC #2616>) that...
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
Got it. Let’s say everything runs fine, but one query or one field returns null because of lack of permission.
Would you recommend returning an error saying why that query returned null? Or let it fail silently? I’m thinking of the format:
@brunolemos That depends on whether the clients need to know (and do something with) the error. If they don’t need to know, then you shouldn’t return it. As for how to return it, you can just throw an error in the resolver, and let GraphQL.js include that in the response. Errors now also include a path, so it automatically tells you which field in the response was affected.