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.
Detect and serialize objects with
null
prototype; provide `shouldJS…
…ONSerializeBody` hook to override behavior (#90) Simplify the JSON serialization conditional to the inverse: Serialize if... * it's an array or plain object * if it has a toJSON() property on it (and isn't a Buffer or FormData-like) Test explicitly that FormData is passed through rather than all non-plain-objects. Passing in a random class is unexpected unless it's meant to be serialized with a toJSON function. Provide `shouldJSONSerializeBody` as an overridable method: The logic to decide on JSON serialization was previously baked in to RESTDataSource. In case customization is desired, we've provided this overridable method as an escape hatch for other use cases.
- Loading branch information
1 parent
2e51657
commit b66da37
Showing
8 changed files
with
180 additions
and
25 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': patch | ||
--- | ||
|
||
Correctly identify and serialize all plain objects (like those with a null prototype) |
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 | ||
--- | ||
|
||
Add a new overridable method `shouldJSONSerializeBody` for customizing body serialization behavior. This method should return a `boolean` in order to inform RESTDataSource as to whether or not it should call `JSON.stringify` on the request body. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,9 @@ circleci | |
codesandbox | ||
datasource | ||
direnv | ||
falsey | ||
httpcache | ||
isplainobject | ||
keyvaluecache | ||
opde | ||
revalidates | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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