-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Avoid costly cloneDeep snapshots when cache results are known to be immutable. #4543
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
48ea511
Create QueryManager in ApolloClient constructor.
benjamn 29c0fa1
Avoid costly cloneDeep calls if { assumeImmutableResults: true }.
benjamn b0a9e4c
Update apollo-boost test that relied on private clientAwareness prope…
benjamn 1e740be
Use invariant.warn to forecast initQueryManager deprecation.
benjamn 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
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
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
Oops, something went wrong.
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'm really happy to see this, but do you think we need to worry about this potentially impacting backcompat? People really shouldn't be setting their own
queryManager
, but we've unfortunately allowed it for a while.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.
@danilobuerger Any thoughts on how risky adding
readonly
might be?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.
What @hwillson said, they shouldn't be setting it, but they might have. But since its just a typing change, its still settable if someone really wanted to. So I don't see an issue with that.
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.
After sleeping on it (and doing a code search for
initQueryManager
andqueryManager
), here's my assessment of the use cases:client.initQueryManager()
is simply to ensureclient.queryManager
exists so it can be examined before the first query happens (e.g. to save a reference toclient.queryManager.queryStore
). These changes render that effort unnecessary.initQueryManager
in an attempt to reset client state. This still works as well as it ever did, becauseinitQueryManager
was previously idempotent, and now does nothing.client.queryManager = null
and later callingclient.initQueryManager()
to recreate it. This no longer works becauseinitQueryManager
won't recreate theQueryManager
now, so addingreadonly
toclient.queryManager
seems like a helpful signal to reconsider this pattern.client.queryManager
somewhere, setting it tonull
temporarily, and then restoring it to the old value later. This still works, as long as you circumvent thereadonly
restriction withclient as any
, which seems like a reasonable "I know what I'm doing" requirement.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.
Good assessment, the only other thing I could come up with is mocking it away for some reason in tests. (However, I don't know why one would want to do that)