-
Notifications
You must be signed in to change notification settings - Fork 20
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
Consider restoring didReceiveResponse
-like hook (for response/error differentiation?)
#109
Comments
This hook was being used in our application to intercept 404 requests from the APIs and return a null data object - now this is removed what is the alternative approach to globally handle specific status codes. 404s were being returned on specific GET requests but in these instances need it handled so no error is thrown as well as return a valid GraphQL response |
A combination of |
Overriding class MyDataSource extends RESTDataSource {
override async fetch<TResult>(
path: string,
incomingRequest: DataSourceRequest = {},
) {
return super.fetch<TResult>(path, incomingRequest).then((result) => {
const response = result.response;
if (!response.ok) {
// mutate response object accordingly
}
return result;
});
}
} |
One additional check done previously in the |
OK think I can solve the above by extracting the content from the |
Just to advise the solution I got working was to use a combination of |
This issue is mostly for seeking feedback from current users.
#107 removed the
didReceiveResponse
hook, which was originally implemented for the purpose of reading headers in addition to the response body. While not its original intention (which was never super well documented), it also afforded users the ability to override the standardresponse.ok
behavior and respond in the face of errors if they chose to. Removing the hook does remove the ability to do this, but we don't know if this capability is something users currently depend on.Generally speaking though, this issue is seeking feedback for use cases that exist for a hook like
didReceiveResponse
. If this sounds interesting to you, please share some details about what you would need from this hook and how it would be useful to you.The text was updated successfully, but these errors were encountered: