This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 787
add client to the mutation result #3417
Merged
hwillson
merged 9 commits into
apollographql:master
from
joshalling:add-client-to-mutation-result
Aug 30, 2019
Merged
add client to the mutation result #3417
hwillson
merged 9 commits into
apollographql:master
from
joshalling:add-client-to-mutation-result
Aug 30, 2019
Conversation
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
joshalling
force-pushed
the
add-client-to-mutation-result
branch
from
August 28, 2019 04:55
ba85e1c
to
89a7d9a
Compare
hwillson
approved these changes
Aug 30, 2019
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.
Thanks very much @joshalling!
hwillson
added a commit
to apollographql/apollo-client
that referenced
this pull request
Jan 9, 2020
apollographql/react-apollo#3417 adjusted `useMutation` to make sure the current `ApolloClient` instance is available in the result returned when `useMutation` is first called. Unfortunately, the changes in that PR are unintentionally modifying the `useState` based `result` object directly, instead of using `setResult`. This is ultimately leading to inconsistencies around the `client` instance sometimes being included in the result and stored as the `previousResult`, and other times not being included. This can then lead to infinite loop / too many render problems caused by the `!equal(this.previousResult, result)` check in `updateResult` always passing, and the state continuously being updated by repeated calls to `setResult`. This commit adjusts the returned `useMutation` result to be a copy of the original `useState` based `result`, which then includes the `client` instance. This ensures the `useState` controlled `result` object is not mutated outside of calling `setResult`, and avoids the infinite loop / too many render issue.
hwillson
added a commit
to apollographql/apollo-client
that referenced
this pull request
Jan 9, 2020
apollographql/react-apollo#3417 adjusted `useMutation` to make sure the current `ApolloClient` instance is available in the result returned when `useMutation` is first called. Unfortunately, the changes in that PR are unintentionally modifying the `useState` based `result` object directly, instead of using `setResult`. This is ultimately leading to inconsistencies around the `client` instance sometimes being included in the result and stored as the `previousResult`, and other times not being included. This can then lead to infinite loop / too many render problems caused by the `!equal(this.previousResult, result)` check in `updateResult` always passing, and the state continuously being updated by repeated calls to `setResult`. This commit adjusts the returned `useMutation` result to be a copy of the original `useState` based `result`, which then includes the `client` instance. This ensures the `useState` controlled `result` object is not mutated outside of calling `setResult`, and avoids the infinite loop / too many render issue.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This fixes #3366
According to the docs the client should be in the result. This updates the result to have the client on MutationData added to the result. If the client is undefined, it will refresh it and add it on there.
Checklist: