-
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
Allow ApolloCache
implementations to specify default value for assumeImmutableResults
client option
#10567
Conversation
🦋 Changeset detectedLatest commit: 2b0a20b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
🎉🎉
throw new InvariantError( | ||
"To initialize Apollo Client, you must specify a 'cache' property " + | ||
"in the options object. \n" + | ||
"For more information, please visit: https://go.apollo.dev/c/docs" |
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.
[Not material to this PR but] TIL that shortlink exists
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.
Yep, and we can add more short links if need be. It would be cool if each error had its own short link with more info.
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.
🎉 🎉 🔥 🔥 This looks great! Super simple change that I think will have a nice impact.
This commit allows the default value of the `assumeImmutableResults` option to be determined by the cache (any implementation of `ApolloCache`), which allows our implementation of `InMemoryCache` to express the safety of assuming `assumeImmutableResults` is `true`, unlocking significant performance savings (fewer defensive deep copies of query results), even if `assumeImmutableResults` is not configured. Related past PRs: - #4543 - #5153 - #9680 - [Apollo Client 2.6 blog post](https://www.apollographql.com/blog/announcement/frontend/whats-new-in-apollo-client-2-6/#rewarding-immutability)
1e82a21
to
2b0a20b
Compare
This commit allows the default value of the
assumeImmutableResults
option to be determined by the cache (any implementation ofApolloCache
), which allows our implementation ofInMemoryCache
to express the safety of assumingassumeImmutableResults
istrue
, unlocking significant performance savings (fewer defensive deep copies of query results), even ifassumeImmutableResults
is not configured.Related past PRs/context: