Allow plugins to set response status code
See original GitHub issueWhen there is an issue that means an entire request has failed, which would normally result in an a 200
status code, it would be useful to be able to return something other than a 200
.
Currently, if we want to change the response via a plugin (within willSendResponse
for example), the following will change it to a 200
, providing the original code was an error code: requestContext.response.http.status = 200;
However, if the response is a 200
, the opposite will not change it to an error code: requestContext.response.http.status = 500;
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:8 (3 by maintainers)
Top Results From Across the Web
HTTP response status codes - MDN Web Docs - Mozilla
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:
Read more >Using Spring @ResponseStatus to Set HTTP Status Code
In this short tutorial, we will see the most straightforward way: using the @ResponseStatus annotation.
Read more >Status codes in HTTP - W3C
Status codes. The values of the numeric status code to HTTP requests are as follows. The data sections of messages Error, Forward and...
Read more >hapi — How to Set Response Status Code - Future Studio
This guide is the first one geared towards responses and precisely shows you how to set the response status code that follows the...
Read more >Set Response Code - Akamai TechDocs
With Status Code set to 200, enable 206 Override to allow the 206 OK status to take precedence. Note: Using the 206 override...
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 Free
Top 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
👍 I’m a user of apollo-server and I really want this feature. We basically monitor the rate of http status code and use it as service level indicator. It’s a difficult problem that how to treat partial errors (some fields are correctly calculated and some are not), but as a first step we’d like to treat partial errors as 5xx error.
Seems related to: https://github.com/apollographql/apollo-server/issues/473
@awinograd Thanks! That worked for me. Just to add some more detail for someone else trying to do this. Create a plugin like so