NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm · #4032 most downloaded on npm
A fully-featured caching GraphQL client.
Last release 16 days ago
18 Sep 2026
Ships fairly regularly
a new release about every 2 weeks
Nearly every release is documented
notes for 60 of the last 60 stable releases
27 versions withdrawn
withdrawn after publishing
7 years old
727 releases · first in 2019
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.
Nothing published for this version
Add GraphQLWsLink in @apollo/client/link/subscriptions. This link is similar to the existing WebSocketLink in @apollo/client/link/ws, but uses the new
Add GraphQLWsLink in @apollo/client/link/subscriptions. This link is similar to the existing WebSocketLink in @apollo/client/link/ws, but uses the newer graphql-ws package and protocol instead of the older subscriptions-transport-ws implementation. <br/>
@glasser in #9369
Note from @benjamn: since
GraphQLWsLinkis new functionality, we would normally wait for the next minor version (v3.6), but we were asked to expedite this release. These changes are strictly additive/opt-in/backwards-compatible, so shipping them in a patch release (3.5.10) seems safe, if unusual.
Interpret keyFields: [...] and keyArgs: [...] configurations in InMemoryCache type/field policies as ReadonlyArrays, since they are never mutated inte
Interpret keyFields: [...] and keyArgs: [...] configurations in InMemoryCache type/field policies as ReadonlyArrays, since they are never mutated internally. <br/>
@julienfouilhe in #9339
Avoid declaring a global type for the __DEV__ constant, to avoid conflict with other such global declarations. <br/>
@benjamn in #9386
Fix useSubscription executing skipped subscription when input changes. <br/>
@levrik in #9299
Fix partial data appearing in useQuery().data when notifyOnNetworkStatusChange: true. <br/>
@brainkim in #9367
Prevent Promises returned by useLazyQuery execute functions from causing unhandled Promise rejection errors if uncaught. <br/>
@brainkim in #9380
Fix the type of the called property returned by useQuery() and useLazyQuery(). @sztadii in #9304
called property returned by useQuery() and useLazyQuery(). <br/>
@sztadii in #9304refetch() not being called when skip is true.useLazyQuery() execution function having stale variables.useLazyQuery() execution function not rejecting when a query errors.Fix regression that prevented calling onError or onCompleted in some cases when using useQuery. @mmahalwy in #9226
Fix regression that prevented calling onError or onCompleted in some cases when using useQuery. <br/>
@mmahalwy in #9226
Make useQuery respect defaultOptions.watchQuery.fetchPolicy. <br/>
@yasharzolmajdi in #9210
Restores old behavior where the callback passed to useMutation() is constant.
…function, whose addition in #8699 was a breaking change (starting in Apollo Client 3.5.0) for direct consumers of selectHttpOptionsAndBody. @benjamn i…
…function, whose addition in #8699 was a breaking change (starting in Apollo Client 3.5.0) for direct consumers of selectHttpOptionsAndBody. @benjamn i…
printer: Printer positional parameter from publicly-exported selectHttpOptionsAndBody function, whose addition in #8699 was a breaking change (starting in Apollo Client 3.5.0) for direct consumers of selectHttpOptionsAndBody.
@benjamn in #9103[Relevant if you use Apollo Client with React Native] Since Apollo Client v3.5.0, CommonJS bundles provided by @apollo/client use a .cjs file extension rather than .cjs.js, so Node.js won't interpret them as ECMAScript modules. While this change should be an implementation detail, it may cause problems for the Metro bundler used by React Native, whose resolver.sourceExts configuration does not include the cjs extension by default.
As a workaround until this issue is resolved, you can configure Metro to understand the .cjs file extension by creating a metro.config.js file in the root of your React Native project:
const { getDefaultConfig } = require("metro-config");
const { resolver: defaultResolver } = getDefaultConfig.getDefaultValues();
exports.resolver = {
...defaultResolver,
sourceExts: [
...defaultResolver.sourceExts,
"cjs",
],
};
Restore the ability to pass onError() and onCompleted() to the mutation execution function.
@brainkim in #9076
Work around webpack 5 errors of the form
The request 'ts-invariant/process' failed to resolve only because it was resolved as fully specified
by ensuring import ... from 'ts-invariant/process' is internally written to import ... from 'ts-invariant/process/index.js'.
@benjamn in #9083
Avoid rewriting non-relative imported module specifiers in config/rewriteModuleIds.ts script, thereby allowing bundlers to resolve those imports as they see fit.
@benjamn in #9073
Ensure only current file is matched when running VSCode debugger. @eps1lon in #9050
Add updateQuery and updateFragment methods to ApolloCache, simplifying common readQuery/writeQuery cache update patterns.
@wassim-k in #8382
Field directives and their arguments can now be included along with field argument names when using field policy keyArgs: [...] notation. For example, if you have a Query.feed field that takes an argument called type and uses a @connection(key:...) directive to keep feed data from different queries separate within the cache, you might configure both using the following InMemoryCache field policy:
new InMemoryCache({
typePolicies: {
Query: {
fields: {
feed: {
keyArgs: ["type", "@connection", ["key"]],
},
},
},
},
})
Report single MissingFieldError instead of a potentially very large MissingFieldError[] array for incomplete cache reads, improving performance and memory usage.
@benjamn in #8734
When writing results into InMemoryCache, each written object is now identified using policies.identify after traversing the fields of the object (rather than before), simplifying identification and reducing duplicate work. If you have custom keyFields functions, they still receive the raw result object as their first parameter, but the KeyFieldsContext parameter now provides context.storeObject (the StoreObject just processed by processSelectionSet) and context.readField (a helper function for reading fields from context.storeObject and any References it might contain, similar to readField for read, merge, and cache.modify functions).
@benjamn in #8996
Ensure cache.identify never throws when primary key fields are missing, and include the source object in the error message when keyFields processing fails.
@benjamn in #8679
The HttpLink constructor now accepts an optional print function that can be used to customize how GraphQL DocumentNode objects are transformed back into strings before they are sent over the network.
@sarahgp in #8699
Make @apollo/client/testing a fully-fledged, independent entry point, instead of re-exporting @apollo/client/utilities/testing (which was never an entry point and no longer exists).
@benjamn in #8769
A new nested entry point called @apollo/client/testing/core has been created. Importing from this entry point instead of @apollo/client/testing excludes any React-related dependencies.
@wassim-k in #8687
Make cache.batch return the result of calling the options.update function.
@benjamn in #8696
The NetworkError and ErrorResponse types have been changed to align more closely.
@korywka in #8424
Update zen-observable-ts to eliminate transitive dependency on @types/zen-observable.
@benjamn in #8695
useLazyQuery function now returns a promise with the result.useMutation result now exposes a method which can be reset.useQuery and useLazyQuery hooks will now have ObservableQuery methods defined consistently.useLazyQuery methods like startPolling will start the query.useLazyQuery execution function will now behave more like refetch. previousData will be preserved.standby fetchPolicies will now act like skip: true more consistently.refetch on a skipped query will have no effect (issue #8270).onError and onCompleted functions from firing continuously, and improving their polling behavior.⚠️ The following advice about
metro.config.jsshould no longer be necessary, as of Apollo Client v3.6.4.
[Relevant if you use Apollo Client with React Native] Since Apollo Client v3.5.0, CommonJS bundles provided by @apollo/client use a .cjs file extension rather than .cjs.js, so Node.js won't interpret them as ECMAScript modules. While this change should be an implementation detail, it may cause problems for the Metro bundler used by React Native, whose resolver.sourceExts configuration does not include the cjs extension by default.
As a workaround until this issue is resolved, you can configure Metro to understand the .cjs file extension by creating a metro.config.js file in the root of your React Native project:
// NOTE: No longer necessary in @apollo/client@3.6.4!
const { getDefaultConfig } = require("metro-config");
const { resolver: defaultResolver } = getDefaultConfig.getDefaultValues();
exports.resolver = {
...defaultResolver,
sourceExts: [...defaultResolver.sourceExts, "cjs"],
};
Restore the ability to pass onError() and onCompleted() to the mutation execution function. <br/> @brainkim in #9076
Work around webpack 5 errors of the form
The request 'ts-invariant/process' failed to resolve only because it was resolved as fully specified
by ensuring import ... from 'ts-invariant/process' is internally written to import ... from 'ts-invariant/process/index.js'. <br/>
@benjamn in #9083
Avoid rewriting non-relative imported module specifiers in config/rewriteModuleIds.ts script, thereby allowing bundlers to resolve those imports as th
Fix useMutation execute function returning non-identical execution functions when passing similar options. @brainkim in #9037
Remove npm from dependencies, and avoid referencing graphql-js enum value. @brainkim in #9030
Add updateQuery and updateFragment methods to ApolloCache, simplifying common readQuery/writeQuery cache update patterns. @wassim-k in #8382
Add updateQuery and updateFragment methods to ApolloCache, simplifying common readQuery/writeQuery cache update patterns. <br/>
@wassim-k in #8382
Field directives and their arguments can now be included along with field argument names when using field policy keyArgs: [...] notation. For example, if you have a Query.feed field that takes an argument called type and uses a @connection(key:...) directive to keep feed data from different queries separate within the cache, you might configure both using the following InMemoryCache field policy:
new InMemoryCache({
typePolicies: {
Query: {
fields: {
feed: {
keyArgs: ["type", "@connection", ["key"]],
},
},
},
},
});
Report single MissingFieldError instead of a potentially very large MissingFieldError[] array for incomplete cache reads, improving performance and memory usage. <br/>
@benjamn in #8734
When writing results into InMemoryCache, each written object is now identified using policies.identify after traversing the fields of the object (rather than before), simplifying identification and reducing duplicate work. If you have custom keyFields functions, they still receive the raw result object as their first parameter, but the KeyFieldsContext parameter now provides context.storeObject (the StoreObject just processed by processSelectionSet) and context.readField (a helper function for reading fields from context.storeObject and any References it might contain, similar to readField for read, merge, and cache.modify functions). <br/>
@benjamn in #8996
Ensure cache.identify never throws when primary key fields are missing, and include the source object in the error message when keyFields processing fails. <br/>
@benjamn in #8679
The HttpLink constructor now accepts an optional print function that can be used to customize how GraphQL DocumentNode objects are transformed back into strings before they are sent over the network. <br/>
@sarahgp in #8699
Make @apollo/client/testing a fully-fledged, independent entry point, instead of re-exporting @apollo/client/utilities/testing (which was never an entry point and no longer exists). <br/>
@benjamn in #8769
A new nested entry point called @apollo/client/testing/core has been created. Importing from this entry point instead of @apollo/client/testing excludes any React-related dependencies. <br/>
@wassim-k in #8687
Make cache.batch return the result of calling the options.update function. <br/>
@benjamn in #8696
The NetworkError and ErrorResponse types have been changed to align more closely. <br/>
@korywka in #8424
Update zen-observable-ts to eliminate transitive dependency on @types/zen-observable. <br/>
@benjamn in #8695
useLazyQuery function now returns a promise with the result.useMutation result now exposes a method which can be reset.useQuery and useLazyQuery hooks will now have ObservableQuery methods defined consistently.useLazyQuery methods like startPolling will start the query.useLazyQuery execution function will now behave more like refetch. previousData will be preserved.standby fetchPolicies will now act like skip: true more consistently.refetch on a skipped query will have no effect (issue #8270).onError and onCompleted functions from firing continuously, and improving their polling behavior.Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Allow TOptions extends FieldFunctionOptions to be passed as final (optional) type parameter of FieldPolicy type. @VictorGaiva in #9000
TOptions extends FieldFunctionOptions to be passed as final (optional) type parameter of FieldPolicy type. <br/>
@VictorGaiva in #9000Prevent webpack from misresolving the graphql package as the local @apollo/client/utilities/globals/graphql.js module when module.exports.resolve.pref
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 removingpreferRelative: truefrom yourwebpack.config.jsfile, or find a way to disable that resolution behavior for packages withinnode_modules.
Avoid importing isType from the graphql package internally, to prevent bundlers from including as much as 3.4kB of unnecessary code. <br/>
@benjamn in #8891
Make client.resetStore and client.clearStore pass appropriate discardWatches option to cache.reset. <br/>
@benjamn in #8873
Require calling cache.reset({ discardWatches: true }) to make cache.reset discard cache.watches, restoring behavior broken in v3.4.14 by #8826. @benja
Disable InMemoryCache result object canonization by default, to prevent unexpected memory growth and/or reuse of object references, with multiple ways
Disable InMemoryCache result 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). <br/>
@benjamn in #8822
Clear InMemoryCache watches set when cache.reset() called. <br/>
@benjamn in #8826
Stop excluding observerless queries from refetchQueries: [...] selection. <br/>
@benjamn in #8825
Prevent optimistic cache evictions from evicting non-optimistic data. <br/> @benjamn in #8829
Ensure cache.broadcastWatch passes all relevant WatchOptions to cache.diff as DiffOptions. <br/>
@benjamn in #8832
Fix componentDidUpate typo in withSubscription higher-order component. @YarBez in #7506
Fix componentDidUpate typo in withSubscription higher-order component. <br/>
@YarBez in #7506
Fix internal canUseSymbol import within @apollo/client/utilities to avoid breaking bundlers/builds. <br/>
@benjamn in #8817
Tolerate unfreezable objects like Uint8Array and Buffer in maybeDeepFreeze. <br/>
@geekuillaume and @benjamn in #8813
Improve handling of falsy existing and/or incoming parameters in relayStylePagination field policy helper function. @bubba and @benjamn in #8733
Improve handling of falsy existing and/or incoming parameters in relayStylePagination field policy helper function. <br/>
@bubba and @benjamn in #8733
Associate Apollo context with React.createContext (instead of using a local WeakMap) again, so multiple copies of @apollo/client (uncommon) can share the same context. <br/>
@benjamn in #8798
Fix Vite tree-shaking by calling the checkDEV() function (at least once) in the module that exports it, @apollo/client/utilities/globals/index.ts. @be
checkDEV() function (at least once) in the module that exports it, @apollo/client/utilities/globals/index.ts. <br/>
@benjamn in #8767PersistedQueryLink namespace from @apollo/client/link/persisted-queries. <br/>
@vedrani in #8761Warn when calling refetch({ variables }) instead of refetch(variables), except for queries that declare a variable named $variables (uncommon). @benja
refetch({ variables }) instead of refetch(variables), except for queries that declare a variable named $variables (uncommon). <br/>
@benjamn in #8702Fix ObservableQuery.getCurrentResult() returning cached data with certain fetch policies. <br/>
@brainkim in #8718
Prevent ssrMode/ssrForceFetchDelay from causing queries to hang. <br/>
@brainkim in #8709
Import @apollo/client/utilities/globals internally wherever __DEV__ is used, not just in @apollo/client/**/index.js entry points. <br/>
@benjamn in #8720
Fix unhandled Promise rejection warnings/errors whose message is Observable cancelled prematurely. @benjamn in #8676
Fix unhandled Promise rejection warnings/errors whose message is Observable cancelled prematurely. <br/>
@benjamn in #8676
Enforce that __DEV__ is polyfilled by every @apollo/client/* entry point that uses it. This build step considers not only explicit __DEV__ usage but also __DEV__ references injected near invariant(...) and new InvariantError(...) expressions. <br/>
@benjamn in #8689
Fix error thrown by nested keyFields: ["a", ["b", "c"], "d"] type policies when writing results into the cache where any of the key fields (.a, .a.b,
Fix error thrown by nested keyFields: ["a", ["b", "c"], "d"] type policies when writing results into the cache where any of the key fields (.a, .a.b, .a.c, or .d) have been renamed by query field alias syntax. <br/>
@benjamn in #8643
Fix regression from PR #8422 (first released in @apollo/client@3.4.0-rc.15) that caused result.data to be set to undefined in some cases after ObservableQuery#getCurrentResult reads an incomplete result from the cache. <br/>
@benjamn in #8642
Fix accidental reuse of recycled MergeTree objects in StoreWriter class used by InMemoryCache. @benjamn in #8618
Reevaluate window.fetch each time HttpLink uses it, if not configured using options.fetch. This change enables a variety of strategies for instrumenti
Reevaluate window.fetch each time HttpLink uses it, if not configured using options.fetch. This change enables a variety of strategies for instrumenting window.fetch, without requiring those strategies to run before @apollo/client/link/http is first imported. <br/>
@benjamn in #8603
Clarify mutation fetchPolicy options ("network-only" or "no-cache") using MutationFetchPolicy union type. <br/>
@benjamn in #8602
Restore full @apollo/client/apollo-client.cjs.js CommonJS bundle for older bundlers.
Note that Node.js and CommonJS bundlers typically use the bundles specified by
"main"fields in our generatedpackage.jsonfiles, which are all independent and non-overlapping CommonJS modules. However,apollo-client.cjs.jsis just one big bundle, so mixing imports ofapollo-client.cjs.jswith the other CommonJS bundles is discouraged, as it could trigger the dual package hazard. In other words, please don't start usingapollo-client.cjs.jsif you're not already. <br/>
Log MissingFieldErrors in ObservableQuery#getCurrentResult using invariant.debug, rather than reporting them via result.error. <br/>
@benjamn in #8604
Fix double registration bug for mutation refetchQueries specified using legacy one-time refetchQueries: [{ query, variables }] style. Though the bug i
Fix double registration bug for mutation refetchQueries specified using legacy one-time refetchQueries: [{ query, variables }] style. Though the bug is fixed, we recommend using refetchQueries: [query] instead (when possible) to refetch an existing query using its DocumentNode, rather than creating, executing, and then deleting a new query, as the legacy { query, variables } style unfortunately does. <br/>
@benjamn in #8586
Fix useQuery/useLazyQuery stalling when clients or queries change. <br/>
@brainkim in #8589
Revert accidental addition of engines.npm section to published version of @apollo/client/package.json. @benjamn in #8578
Fix { ssr: false } causing queries to hang on the client. @brainkim in #8574
Use more default type parameters for mutation-related types in react/types/types.ts, to provide smoother backwards compatibility for code using those
Initialize stringifyCanon lazily, when canonicalStringify is first called, fixing Uncaught ReferenceError: __DEV__ is not defined errors due to usage
Refetching queries with client.refetchQueries. @StephenBarlow and @benjamn in #8265
client.refetchQueries.
@StephenBarlow and @benjamn in #8265InMemoryCache 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
Add expected/received variables to No more mocked responses... error messages generated by MockLink.
@markneub in #8340
The InMemoryCache version of the cache.gc method now supports additional options for removing non-essential (recomputable) result caching data.
@benjamn in #8421
Suppress noisy Missing cache result fields... warnings by default unless setLogVerbosity("debug") called.
@benjamn in #8489
Improve interaction between React hooks and React Fast Refresh in development. @andreialecu in #7952
To avoid retaining sensitive information from mutation root field arguments, Apollo Client v3.4 automatically clears any ROOT_MUTATION fields from the cache after each mutation finishes. If you need this information to remain in the cache, you can prevent the removal by passing the keepRootFields: true option to client.mutate. ROOT_MUTATION result data are also passed to the mutation update function, so we recommend obtaining the results that way, rather than using keepRootFields: true, if possible.
@benjamn in #8280
Internally, Apollo Client now controls the execution of development-only code using the __DEV__ global variable, rather than process.env.NODE_ENV. While this change should not cause any visible differences in behavior, it will increase your minified+gzip bundle size by more than 3.5kB, unless you configure your minifier to replace __DEV__ with a true or false constant, the same way you already replace process.env.NODE_ENV with a string literal like "development" or "production". For an example of configuring a Create React App project without ejecting, see this pull request for our React Apollo reproduction template.
@benjamn in #8347
Internally, Apollo Client now uses namespace syntax (e.g. import * as React from "react") for imports whose types are re-exported (and thus may appear in .d.ts files). This change should remove any need to configure esModuleInterop or allowSyntheticDefaultImports in tsconfig.json, but might require updating bundler configurations that specify named exports of the react and prop-types packages, to include exports like createContext and createElement (example).
@devrelm in #7742
Respect no-cache fetch policy (by not reading any data from the cache) for loading: true results triggered by notifyOnNetworkStatusChange: true.
@jcreighton in #7761
The TypeScript return types of the getLastResult and getLastError methods of ObservableQuery now correctly include the possibility of returning undefined. If you happen to be calling either of these methods directly, you may need to adjust how the calling code handles the methods' possibly-undefined results.
@benjamn in #8394
Log non-fatal invariant.error message when fields are missing from result objects written into InMemoryCache, rather than throwing an exception. While this change relaxes an exception to be merely an error message, which is usually a backwards-compatible change, the error messages are logged in more cases now than the exception was previously thrown, and those new error messages may be worth investigating to discover potential problems in your application. The errors are not displayed for @client-only fields, so adding @client is one way to handle/hide the errors for local-only fields. Another general strategy is to use a more precise query to write specific subsets of data into the cache, rather than reusing a larger query that contains fields not present in the written data.
@benjamn in #8416
The nextFetchPolicy option for client.watchQuery and useQuery will no longer be removed from the options object after it has been applied, and instead will continue to be applied any time options.fetchPolicy is reset to another value, until/unless the options.nextFetchPolicy property is removed from options.
@benjamn in #8465
The fetchMore, subscribeToMore, and updateQuery functions returned from the useQuery hook may now return undefined in edge cases where the functions are called when the component is unmounted.
@noghartt in #7980
In Apollo Client 2.x, a refetch operation would always replace existing data in the cache. With the introduction of field policy merge functions in Apollo Client 3, existing field values could be inappropriately combined with incoming field values by a custom merge function that does not realize a refetch has happened.
To give you more control over this behavior, we have introduced an overwrite?: boolean = false option for cache.writeQuery and cache.writeFragment, and an option called refetchWritePolicy?: "merge" | "overwrite" for client.watchQuery, useQuery, and other functions that accept WatchQueryOptions. You can use these options to make sure any merge functions involved in cache writes for refetch operations get invoked with undefined as their first argument, which simulates the absence of any existing data, while still giving the merge function a chance to determine the internal representation of the incoming data.
The default behaviors are overwrite: true and refetchWritePolicy: "overwrite", which restores the Apollo Client 2.x behavior, but (if this change causes any problems for your application) you can easily recover the previous merging behavior by setting a default value for refetchWritePolicy in defaultOptions.watchQuery:
new ApolloClient({
defaultOptions: {
watchQuery: {
refetchWritePolicy: "merge",
},
},
})
Make sure the MockedResponse ResultFunction type is re-exported.
@hwillson in #8315
InMemoryCache now coalesces EntityStore updates to guarantee only one store.merge(id, fields) call per id per cache write.
@benjamn in #8372
Fix polling when used with <React.StrictMode>.
@brainkim in #8414
Fix the React integration logging Warning: Can't perform a React state update on an unmounted component.
@wuarmin in #7745
Make ObservableQuery#getCurrentResult always call queryInfo.getDiff().
@benjamn in #8422
Make readField default to reading from current object only when the from option/argument is actually omitted, not when from is passed to readField with an undefined value. A warning will be printed when this situation occurs.
@benjamn in #8508
The fetchMore, subscribeToMore, and updateQuery functions no longer throw undefined errors.
@noghartt in #7980
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →