generated from apollographql/typescript-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New throwIfResponseIsError hook (#115)
We previously removed `didReceiveResponse` which let you override the main "is it an error or not" logic. This restores it in an error-specific way. This means you can throw errors even on 200s if you want (or vice versa). This also changes the `errorFromResponse` hook to take options instead of a single argument, in case you want the error to reflect more data. One negative change is you can no longer prevent `parseBody` from being called, though you can always override `parseBody` to do less. Fixes #32.
- Loading branch information
Showing
4 changed files
with
70 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@apollo/datasource-rest': major | ||
--- | ||
|
||
The `errorFromResponse` method now receives an options object with `url`, `request`, `response`, and `parsedBody` rather than just a response, and the body has already been parsed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@apollo/datasource-rest': minor | ||
--- | ||
|
||
New `throwIfResponseIsError` hook allows you to control whether a response should be returned or thrown as an error. Partially replaces the removed `didReceiveResponse` hook. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters