@apollo/client
4.3.5 · 19 Oct 2026MIT5.3M / weekRepositoryHomepagenpmAtom feed
3.14.1 is the newest release of 3.x.
In short
6 breaking11 new4 fixed
- breaking
Ensure
cache.readQueryandcache.readFragmentalways returnTData | null, instead of throwingMissingFieldErrorexceptions when missing fields are encountered. - breaking
HttpLinkwill now automatically strip any unusedvariablesbefore sending queries to the GraphQL server, since those queries are very likely to fail validation, according to the All Variables Used rule in the GraphQL specification. If you depend on the preservation of unused variables, you can restore the previous behavior by passingincludeUnusedVariables: trueto theHttpLinkconstructor (which is typically passed asoptions.linkto theApolloClientconstructor). - breaking
Ensure
MockLink(used byMockedProvider) returns mock configuration errors (e.g.No more mocked responses for the query ...) through the Link'sObservable, instead of throwing them. These errors are now available through theerrorproperty of a result. - breaking
Unsubscribing the last observer from an
ObservableQuerywill once again unsubscribe from the underlying networkObservablein all cases, as in Apollo Client 2.x, allowing network requests to be cancelled by unsubscribing. - breaking
The independent
QueryBaseOptionsandModifiableWatchQueryOptionsinterface supertypes have been eliminated, and their fields are now defined byQueryOptions. - breaking
Internally, Apollo Client now avoids nested imports from the
graphqlpackage, importing everything from the top-level package instead. For example,
Release note
Apollo Client 3.3.0
Bug Fixes
Update
@wry/equalityto consider undefined properties equivalent to missing properties.
@benjamn in #7108Prevent memory leaks involving unused
onBroadcastfunction closure created inApolloClientconstructor.
@kamilkisiela in #7161Provide default empty cache object for root IDs like
ROOT_QUERY, to avoid differences in behavior before/afterROOT_QUERYdata has been written intoInMemoryCache.
@benjamn in #7100Cancel
queryInfo.notifyTimeoutinQueryInfo#markResultto prevent unnecessary network requests when using aFetchPolicyofcache-and-networkornetwork-onlyin a React component with multipleuseQuerycalls.
@benjamn in #7347
Potentially breaking changes
- breaking
Ensure
cache.readQueryandcache.readFragmentalways returnTData | null, instead of throwingMissingFieldErrorexceptions when missing fields are encountered.
@benjamn in #7098Since this change converts prior exceptions to
nullreturns, and sincenullwas already a possible return value according to theTData | nullreturn type, we are confident this change will be backwards compatible (as long asnullwas properly handled before). - breaking
HttpLinkwill now automatically strip any unusedvariablesbefore sending queries to the GraphQL server, since those queries are very likely to fail validation, according to the All Variables Used rule in the GraphQL specification. If you depend on the preservation of unused variables, you can restore the previous behavior by passingincludeUnusedVariables: trueto theHttpLinkconstructor (which is typically passed asoptions.linkto theApolloClientconstructor).
@benjamn in #7127 - breaking
Ensure
MockLink(used byMockedProvider) returns mock configuration errors (e.g.No more mocked responses for the query ...) through the Link'sObservable, instead of throwing them. These errors are now available through theerrorproperty of a result.
@hwillson in #7110Returning mock configuration errors through the Link's
Observablewas the default behavior in Apollo Client 2.x. We changed it for 3, but the change has been problematic for those looking to migrate from 2.x to 3. We've decided to change this back with the understanding that not many people want or are relying onMockLink's throwing exception approach. If you want to change this functionality, you can define custom error handling throughMockLink.setOnError. - breaking
Unsubscribing the last observer from an
ObservableQuerywill once again unsubscribe from the underlying networkObservablein all cases, as in Apollo Client 2.x, allowing network requests to be cancelled by unsubscribing.
@javier-garcia-meteologica in #7165 and #7170. - breaking
The independent
QueryBaseOptionsandModifiableWatchQueryOptionsinterface supertypes have been eliminated, and their fields are now defined byQueryOptions.
@DCtheTall in #7136 - breaking
Internally, Apollo Client now avoids nested imports from the
graphqlpackage, importing everything from the top-level package instead. For example,import { visit } from "graphql/language/visitor";is now just
import { visit } from "graphql";Since the
graphqlpackage uses.mjsmodules, your bundler may need to be configured to recognize.mjsfiles as ECMAScript modules rather than CommonJS modules.
@benjamn in #7185
Improvements
Support inheritance of type and field policies, according to
possibleTypes.
@benjamn in #7065Allow configuring custom
mergefunctions, including themerge: trueandmerge: falseshorthands, in type policies as well as field policies.
@benjamn in #7070The verbosity of Apollo Client console messages can be globally adjusted using the
setLogVerbosityfunction:import { setLogVerbosity } from "@apollo/client"; setLogVerbosity("log"); // display all messages setLogVerbosity("warn"); // display only warnings and errors (default) setLogVerbosity("error"); // display only errors setLogVerbosity("silent"); // hide all console messagesRemember that all logs, warnings, and errors are hidden in production.
@benjamn in #7226Modifying
InMemoryCachefields that havekeyArgsconfigured will now invalidate only the field value with matching key arguments, rather than invalidating all field values that share the same field name. IfkeyArgshas not been configured, the cache must err on the side of invalidating by field name, as before.
@benjamn in #7351Shallow-merge
options.variableswhen combining existing or default options with newly-provided options, so new variables do not completely overwrite existing variables.
@amannn in #6927Avoid displaying
Cache data may be lost...warnings for scalar field values that happen to be objects, such as JSON data.
@benjamn in #7075In addition to the
result.dataproperty,useQueryanduseLazyQuerywill now provide aresult.previousDataproperty, which can be useful when a network request is pending andresult.datais undefined, sinceresult.previousDatacan be rendered instead of rendering an empty/loading state.
@hwillson in #7082Passing
validate: trueto theSchemaLinkconstructor will enable validation of incoming queries against the local schema before execution, returning validation errors inresult.errors, just like a non-local GraphQL endpoint typically would.
@amannn in #7094Allow optional arguments in
keyArgs: [...]arrays forInMemoryCachefield policies.
@benjamn in #7109Avoid registering
QueryPromisewhenskipistrueduring server-side rendering.
@izumin5210 in #7310ApolloCacheobjects (includingInMemoryCache) may now be associated with or disassociated from individual reactive variables by callingreactiveVar.attachCache(cache)and/orreactiveVar.forgetCache(cache).
@benjamn in #7350