generated from apollographql/typescript-repo-template
-
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
Detect and serialize objects with null
prototype; provide shouldJSONSerializeBody
hook to override behavior
#90
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0dc8c64
failing test
trevor-scheer e1e0d6a
implement fix, failing test passes
trevor-scheer 54849ec
fix falsely passing test
trevor-scheer 4009bef
update solution and broken test
trevor-scheer 8812f12
update dictionary
trevor-scheer 941f1b6
changeset
trevor-scheer a19232c
Simplify serialization conditional
trevor-scheer 82eda41
prettier
trevor-scheer 1055c92
Provide `shouldJSONSerializeBody` as an overridable method
trevor-scheer ed5ca51
additional changeset
trevor-scheer 0ddf2f1
pin dev dep
trevor-scheer 595a755
use optional chain
trevor-scheer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i still kinda feel like "anything but string or Buffer" or "anything but string, Buffer, or FormData" would be a better default — the goal of this is to produce something that the Fetch API understands, and so it feels like we should serialize anything other than what Fetch understands.
On the other hand, real Fetch APIs also take other stuff like readable streams, URLSearchParameters, TypedArray, Blob, etc, and perhaps your choice here is better for those things (and we're already moving away from "serialize anything that our Fetcher interface doesn't expect" due to FormData).
So I guess this does seem fine, given that it's just a default people can change.