InMemoryCache now guarantees that any two result objects returned by the cache (from readQuery, readFragment, etc.) will be referentially equal (===) if they are deeply equal. Previously, === equality was often achievable for results for the same query, on a best-effort basis. Now, equivalent result objects will be automatically shared among the result trees of completely different queries. This guarantee is important for taking full advantage of optimistic updates that correctly guess the final data, and for "pure" UI components that can skip re-rendering when their input data are unchanged.
@benjamn in #7439
Mutations now accept an optional callback function called onQueryUpdated, which will be passed the ObservableQuery and Cache.DiffResult objects for any queries invalidated by cache writes performed by the mutation's final update function. Using onQueryUpdated, you can override the default FetchPolicy of the query, by (for example) calling ObservableQuery methods like refetch to force a network request. This automatic detection of invalidated queries provides an alternative to manually enumerating queries using the refetchQueries mutation option. Also, if you return a Promise from onQueryUpdated, the mutation will automatically await that Promise, rendering the awaitRefetchQueries option unnecessary.
@benjamn in #7827
Support client.refetchQueries as an imperative way to refetch queries, without having to pass options.refetchQueries to client.mutate.
@dannycochran in #7431
Improve standalone client.refetchQueries method to support automatic detection of queries needing to be refetched.
@benjamn in #8000
Fix remaining barriers to loading @apollo/client/core as native ECMAScript modules from a CDN like esm.run. Importing @apollo/client from a CDN will become possible once we move all React-related dependencies into @apollo/client/react in Apollo Client 4.
@benjamn in #8266
InMemoryCache supports a new method called batch, which is similar to performTransaction but takes named options rather than positional parameters. One of these named options is an onDirty(watch, diff) callback, which can be used to determine which watched queries were invalidated by the batch operation.
@benjamn in #7819
Allow merge: true field policy to merge Reference objects with non-normalized objects, and vice-versa.
@benjamn in #7778
Allow identical subscriptions to be deduplicated by default, like queries.
@jkossis in #6910
Always use POST request when falling back to sending full query with @apollo/client/link/persisted-queries.
@rieset in #7456
The FetchMoreQueryOptions type now takes two instead of three type parameters (<TVariables, TData>), thanks to using Partial<TVariables> instead of K extends typeof TVariables and Pick<TVariables, K>.
@ArnaudBarre in #7476
Pass variables and context to a mutation's update function. Note: The type of the update function is now named MutationUpdaterFunction rather than MutationUpdaterFn, since the older type was broken beyond repair. If you are using MutationUpdaterFn in your own code, please use MutationUpdaterFunction instead.
@jcreighton in #7902
A resultCacheMaxSize option may be passed to the InMemoryCache constructor to limit the number of result objects that will be retained in memory (to speed up repeated reads), and calling cache.reset() now releases all such memory.
@SofianHn in #8701
Fully remove result cache entries from LRU dependency system when the corresponding entities are removed from InMemoryCache by eviction, or by any other means.
@sofianhn and @benjamn in #8147
Prevent webpack from misresolving the graphql package as the local @apollo/client/utilities/globals/graphql.js module when module.exports.resolve.preferRelative is enabled in webpack.config.js.
Note: if you encounter strange module resolution errors like export 'isType' (imported as 'isType') was not found in 'graphql' (possible exports: removeTemporaryGlobals) please try removing preferRelative: true from your webpack.config.js file, or find a way to disable that resolution behavior for packages within node_modules.
Avoid importing isType from the graphql package internally, to prevent bundlers from including as much as 3.4kB of unnecessary code.
@benjamn in #8891
Make client.resetStore and client.clearStore pass appropriate discardWatches option to cache.reset.
@benjamn in #8873
Apollo Client 3.4.15
Bug Fixes
Require calling cache.reset({ discardWatches: true }) to make cache.reset discard cache.watches, restoring behavior broken in v3.4.14 by #8826.
@benjamn in #8852
Apollo Client 3.4.14
Bug Fixes
Disable InMemoryCacheresult object canonization by default, to prevent unexpected memory growth and/or reuse of object references, with multiple ways to reenable it (per-cache, per-query, or a mixture of both).
@benjamn in #8822
Clear InMemoryCachewatches set when cache.reset() called.
@benjamn in #8826
Stop excluding observerless queries from refetchQueries: [...] selection.
@benjamn in #8825
Prevent optimistic cache evictions from evicting non-optimistic data.
@benjamn in #8829
Ensure cache.broadcastWatch passes all relevant WatchOptions to cache.diff as DiffOptions.
@benjamn in #8832
Apollo Client 3.4.13
Bug Fixes
Fix componentDidUpate typo in withSubscription higher-order component.
@YarBez in #7506
Fix internal canUseSymbol import within @apollo/client/utilities to avoid breaking bundlers/builds.
... (truncated)
Commits
eb9f62a Bump @apollo/client npm version to 3.4.16.
58ae8b8 Make client.{reset,clear}Store pass discardWatches to cache.reset (#8873)
7620b5b Avoid unnecessarily importing isType from graphql package (#8891)
b63a3f5 Merge pull request #8890 from apollographql/sb/docs-rc-notice
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Bumps @apollo/client from 3.3.20 to 3.4.16.
Release notes
Sourced from
@apollo/client
's releases.... (truncated)
Changelog
Sourced from
@apollo/client
's changelog.... (truncated)
Commits
eb9f62a
Bump@apollo/client
npm version to 3.4.16.58ae8b8
Makeclient.{reset,clear}Store
passdiscardWatches
tocache.reset
(#8873)7620b5b
Avoid unnecessarily importingisType
fromgraphql
package (#8891)b63a3f5
Merge pull request #8890 from apollographql/sb/docs-rc-noticeae8ae50
Add preview links for new methods3304c55
Add a temporary notice about 3.5 release candidate17df471
chore(deps): update dependency@types/react
to v17.0.27c330051
chore(deps): update dependency@types/node
to v16.10.2e16b672
chore(deps): update dependency@types/react
to v17.0.26b964d24
chore(deps): update dependency@types/lodash
to v4.14.175Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)