npm / @apollo/client
@apollo/client
What changed in @apollo/client 4, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-27.
265 breaking20 deprecations19 new APIs and options11 behavior and defaults1 tooling13 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@apollo/client 4329 changes
Breaking changes 265
The variables option is required when a fragment has required variables, matching useSuspenseFragment and the query hooks.
Field aliases beginning with __ac_ are forbidden because the namespace is reserved for internal use.
Outgoing requests now default to application/graphql-response+json,application/json;q=0.9 as the Accept header.
ApolloClient.addResolvers has been removed; add resolvers through the client's LocalState instance.
The core entry point is renamed to @apollo/client.
The link/core entry point is renamed to @apollo/client/link.
React exports move from @apollo/client to @apollo/client/react, requiring React applications to update imports.
The render prop components entry point is removed in Apollo Client 4.
This entry point was removed; use @apollo/client/react instead.
The higher order components entry point is removed in Apollo Client 4.
The React hooks entry point is consolidated into @apollo/client/react.
The parser entry point is removed along with the render prop components and HOCs it implemented.
The testing/core entry point is renamed to @apollo/client/testing.
The testing/core entrypoint is removed; import from @apollo/client/testing instead.
The experimental testing entry point is removed; the notes point to @apollo/graphql-testing-library as the available alternative.
Internal testing utilities moved here; utilities and types remaining at @apollo/client/testing are now considered stable.
MockedProvider moved from @apollo/client/testing to this entry point.
The utilities/globals entry point is removed as an implementation detail; some exports are available in other entry points.
Most utilities moved to this entry point; utilities and types remaining at @apollo/client/utilities are documented and considered stable.
The urql subscriptions entry point is removed because urql supports this natively.
A type-only migration entry point provides doc blocks for removed exports; importing runtime values from it throws at runtime.
The clientAwareness option now holds name and version, which move out of the top-level constructor options.
Move credentials from the ApolloClient constructor options to the link option, configuring them on an HttpLink instance.
Certain default options cannot be passed to the constructor unless declared through DeclareDefaultOptions; other defaultOptions remain allowed.
The connectToDevTools option is replaced by devtools, which contains an enabled property.
Replace connectToDevTools with devtools.enabled to configure DevTools.
Move headers from the ApolloClient constructor options to the link option, configuring them on an HttpLink instance.
Incremental delivery is configurable and requires an incremental handler; applications using @defer can provide Defer20220824Handler.
The link option is now required; ApolloClient no longer creates an implicit HttpLink.
Configure local state with a LocalState instance and move resolvers into that instance; typeDefs and fragmentMatcher options are removed.
Rename disableNetworkFetches to prioritizeCacheValues.
Move uri from the ApolloClient constructor options to the link option, configuring it on an HttpLink instance.
uri, headers, and credentials were removed from ApolloClient options; configure HttpLink directly.
Use declaration merging to declare default errorPolicy and returnPartialData values at the type level, allowing query, mutation, and hook result types to reflect those defaults.
ObservableQueries are registered only while they have subscribers, so this method returns only queries with at least one subscriber.
The local resolvers API was removed from ApolloClient in favor of localState.
Provide a LocalState instance through this constructor option to enable local state management; using @client without it throws an error.
ApolloClientOptions is now named ApolloClient.Options; related ApolloClient types are namespaced under ApolloClient.
Renames disableNetworkFetches; queries made while enabled apply a replacement fetch policy only for that request, without changing the ObservableQuery's original fetchPolicy.
Only queries with at least one subscriber can be returned or refetched; active and inactive query meanings also changed.
Removes the resolvers option; configure resolvers in a LocalState instance assigned to localState.
The resolvers constructor option has been removed; configure local resolvers on the LocalState instance instead.
The local resolvers API was removed from ApolloClient in favor of localState.
The local resolvers API was removed from ApolloClient in favor of localState.
stop() now unsubscribes active ObservableQuery instances, rejects in-flight queries, and removes queryRefs from the suspense cache.
ApolloConsumer has been removed; use useApolloClient instead.
The ApolloError class was removed; errors are no longer universally wrapped in this class.
Use the ApolloLink.concat static method instead of the concat function exported from @apollo/client/link.
Use the ApolloLink.from static method instead of the from function exported from @apollo/client/link.
The from, concat, and split static and instance methods now require ApolloLink instances; wrap request handler functions in an ApolloLink.
A request handler must return an Observable; use RxJS EMPTY instead of null for an empty observable.
Use the ApolloLink.split static method instead of the split function exported from @apollo/client/link.
execute now requires a third argument containing the client that initiated the request.
Removes the onError and setOnError methods from ApolloLink.
The request handler always receives forward, which is no longer optional; calling it from a terminating link warns and returns an immediately completing observable that results in a client error.
ApolloLink.Request no longer accepts operationName or operationType; those properties are derived from query and set on ApolloLink.Operation.
FetchResult is now ApolloLink.Result.
Using an incremental delivery handler now requires explicitly opting into its chunk types through TypeOverrides module augmentation.
Properties such as called and refetch that are not included in ApolloQueryResult must be read from the hook instead.
The data field type is now TData | undefined, reflecting its possible runtime value.
Responses use the specification's application/json behavior; non-200 responses encoded as application/json or another content type now throw ServerError.
A non-200 response with this content type now throws ServerError.
The utility was removed; use an RxJS operator such as from to create Observables from promises.
Removes the base React hook types; use the hook types instead.
includeExtensions now defaults to true; empty or unset extensions are not included in outgoing requests.
With no cached data, cache-only queries initialize with loading: false and NetworkStatus.ready.
Cache-only queries no longer poll; a warning is emitted, and changing to cache-only stops active polling.
With returnPartialData true and an empty result, cache.diff returns null instead of an empty object; callers and cache implementations must handle or return null.
With returnPartialData false and an incomplete result, cache.diff returns null instead of throwing; callers and cache implementations must check for or return null.
fragmentMatches is required, and data masking may crash if it is missing.
The generic arguments are now ordered TData, TVariables instead of TVariables, TData.
The option was removed because it caused memory leaks; object identity may differ for objects that were previously referentially equal.
client.mutate and useMutation now return MutateResult instead of FetchResult; errors are reported through error rather than errors.
client.query no longer supports fetchPolicy standby, which does not fetch or return data and is intended for watched queries.
Document transforms are applied before reading from the cache; use cache.readQuery to read without running transforms.
cache-only queries are no longer refetched when includeStandby is true.
Named queries in standby are now refetched; use onQueryUpdated to skip standby queries and retain v3 behavior.
cache-only queries are excluded from refetchQueries in all situations, including updateCache effects when onQueryUpdated is absent.
Calling client.subscribe no longer eagerly starts a subscription; subscribe to the returned observable to start it.
The clientErrors property has no replacement; non-GraphQL and non-protocol errors are passed through as-is.
ClientParseError was removed; JSON serialization errors are thrown directly.
GraphQL errors are represented by CombinedGraphQLErrors; use its is method to identify them and read the raw errors property.
Protocol errors are encapsulated in CombinedProtocolErrors; use its is method to check an error and read raw protocol errors from the errors property.
concat, from, and split no longer accept a plain request handler function; wrap it with new ApolloLink.
Removes the deprecated ApolloClientOptions option; use devtools.enabled instead.
This testing utility has been removed; use MockLink directly with an ApolloClient instance.
createOperation now returns a well-formed Operation; callers should pass the request directly without transformOperation or validateOperation.
createOperation no longer accepts context as its first argument; put context on the request passed to createOperation.
disable and retry callbacks now receive a single error property instead of graphQLErrors and networkError.
The callback response property was renamed to result.
Applications using data masking need global type augmentation to enable data masking types when dataMasking is true.
The DataMasking interface is no longer exported from @apollo/client or @apollo/client/masking.
The data masking types mode has been removed and the mode key has no effect; Masked and MaskedDocumentNode are also removed.
The DataProxy namespace and interface were removed.
TContext generic arguments were removed from types that used them and replaced with DefaultContext, which can be modified using declaration merging.
Applications using @defer need to enable incremental delivery and configure an incrementalHandler.
HttpLink and BatchHttpLink now send client library name and version in extensions by default; disable transport awareness with enhancedClientAwareness: { transport: false }.
Errors from results are unified in the error property; remove checks for the errors property.
Error handling uses a unified error property, granular error classes, and consistent errorPolicy behavior for all error types.
A class-based replacement for onError; its callback receives a single error property instead of separate GraphQL, network, and protocol error properties.
Network errors now follow errorPolicy: policies other than none resolve promises, while network-error data is undefined.
Network errors from queries now adhere to errorPolicy like GraphQL errors; promise-based APIs can resolve with the error property set when policy is ignore.
Mutation network errors now follow errorPolicy: all resolves the promise and returns the error property, while none strips the error.
The execute function only accepts variables and context; other options must be provided to the hook, with changed values applied by rerendering before execution.
Calling execute during render now throws an error; use useQuery for queries that should execute during render.
In-flight queries are aborted when the component unmounts or a new execution starts; call retain on the returned promise to let a query run to completion.
The promise now resolves or rejects according to errorPolicy for all error types; none rejects, all resolves with error, and ignore resolves while discarding errors.
Direct calls now require a third argument providing the ApolloClient instance that initiated the request.
Export fields are validated before requests: they require a matching variable definition, and required variables cannot resolve to null or undefined.
The package defines an exports field so bundlers resolve module formats through entry points instead of direct .js or .cjs imports.
Calling fetchMore on a cache-only query now throws an error.
errorPolicy now defaults to none instead of being inherited, preventing accidental cache writes of partial paginated-query data.
When query is specified, unspecified options other than variables are inherited from the underlying ObservableQuery.
Without query, variables are shallowly merged with the underlying ObservableQuery variables; with query, fetchMore variables are used instead.
The ApolloClient fragmentMatcher option has been removed; fragment matching is now part of the cache through fragmentMatches.
Fragment matching is now a cache API; custom cache implementations used with LocalState must implement it.
Use the rxjs from function instead of Observable.from.
The zen-observable utility was removed; use RxJS throwError instead.
The zen-observable utility was removed; use RxJS from instead.
The context function for obtaining cache IDs has been removed; use operation.client.cache.identify instead.
ApolloClient.getResolvers has been removed without a replacement.
Removes the deprecated graphql, withQuery, withMutation, withSubscription, and withApollo HOC components; use React hooks instead.
graphql v15 is no longer a valid peer dependency.
The TVariables generic argument was removed from GraphQLRequest.
An error is thrown if the connection closes before the final boundary; data after the final boundary is ignored.
Apollo-provided createHttpLink usage migrates to the HttpLink class, instantiated with new.
includeExtensions now defaults to true; empty or unset extensions are not included in outgoing requests.
Create and pass an HttpLink through ApolloClient's link option; the uri, headers, and credentials constructor options no longer implicitly create one.
The resetResultIdentities option was removed because object canonization was removed.
The utility was removed; check for the specific error types that replace ApolloError.
A synchronous link-chain response omits the loading state; an asynchronous response triggers it.
Thrown local resolver errors are added to the GraphQL response errors array and the field value is set to null.
Resolvers must return a value or null; undefined becomes null and logs a warning, except for exported-variable resolution.
Local state is opt-in: create a LocalState instance and pass it as ApolloClient's localState option; move local resolvers into its constructor.
A client-only query in a mocked response now throws an error.
Mocks without a specified delay now use a random realistic delay between 20 and 50ms; set delay to 0 to restore no delay.
This testing utility was removed; use MockSubscriptionLink instead.
This testing utility was removed; use MockLink instead.
The deprecated Mutation React component was removed; use the provided React hooks instead.
Network errors are returned as-is rather than wrapped; use the error property directly.
The newData option was removed from MockLink and MockedProvider mocks; use result as a callback with maxUsageCount set to Number.POSITIVE_INFINITY.
The option now defaults to true for React hooks and ObservableQuery instances created by client.watchQuery; set the global watchQuery default to false to restore v3 behavior.
This is the default incremental delivery handler and throws if @defer is used.
Observable instances now use rxjs, so instance methods such as map, filter, reduce, flatMap, and concat must be replaced with rxjs equivalents.
When cache data cannot fulfill a query, its first emitted result is now a loading state.
Previous data is retained during loading emissions unless the query or variables changed.
Removes errors from ObservableQuery results and client.query results; read errors from error instead.
With fetchPolicy set to standby, ObservableQuery returns loading: false even before subscription.
The saveAsLastResult argument has been dropped.
Removes getLastResult, getLastError, and resetLastResults from ObservableQuery.
Removes queryId from ObservableQuery; getObservableQueries now returns a Set rather than a Map.
ObservableQuery.result() was removed; use RxJS firstValueFrom with the observable instead.
setOptions was removed as an alias of reobserve; use reobserve directly, which is now public.
Calling reobserve with variables: undefined resets variables to empty instead of leaving them unchanged.
The client tracks ObservableQuery instances only while they have subscribers, changing which queries client APIs consider active or inactive and avoiding unnecessary refetches.
ObservableQuery no longer inherits from Observable; use RxJS from when an API requires an Observable. It still supports subscribe and pipe.
Network errors no longer emit an error notification or terminate observables; read errors from result.error in the next callback.
Unsubscribing while a request is in flight no longer terminates the request by unsubscribing from the link observable.
Unsubscribing before the first value removes the query from the tracked query list, making it ineligible for query deduplication.
When notifyOnNetworkStatusChange is true, subscribing emits an initial loading state.
Use the rxjs of function instead of Observable.of.
The link callback now reports the cause through a single error property instead of separate GraphQL, network, and protocol error properties.
The response property in the onError link has been renamed to result.
Links can access the ApolloClient instance that initiated the request, including its cache.
The returned context object is now frozen and Readonly. Use operation.setContext() to make changes so they propagate to downstream links.
The cache property has been removed from operation context; access the cache through operation.client.cache instead.
The forceFetch context property is removed and replaced by queryDeduplication, which indicates whether deduplication was enabled for the request.
The property is now a non-null OperationTypeNode and can be compared without checking for undefined.
Use this method to change operation context now that the object returned by operation.getContext() is frozen and Readonly.
OperationBatcher is no longer exported from @apollo/client/link/batch and should not be used directly.
Anonymous queries now set operationName to undefined rather than an empty string; check for undefined before using string methods.
The package now exposes entry points through the root package.json exports field; proxy-directory package.json files were removed.
The deprecated partialRefetch option was removed.
Apollo Client has stopped shipping polyfills; older browsers or special environments may need their own polyfills.
toPromise moved from queryRef to the preloadQuery function; pass the queryRef to preloadQuery.toPromise, making queryRef objects more serializable for SSR.
This SSR API replaces deprecated SSR functions and works with React 19 prerender APIs.
In useLazyQuery, previousData changes only when data changes; it no longer changes to the same value as data while loading.
Apollo Client defaults to production rather than development when the environment cannot be determined or globalThis.__DEV__ is not true.
The loading property was removed from promise-based query API results because promise resolution guarantees the query is no longer loading.
The networkStatus property was removed from promise-based query API results.
The partial property was removed from promise-based query API results.
Queries and mutations now throw an error if the link chain completes without emitting a value.
The deprecated Query React component was removed; use the provided React hooks instead.
Subscriptions are deduplicated by default when they qualify; set queryDeduplication to false in the subscription context to create a separate connection.
The QueryReference type is renamed QueryRef.
DataState now modifies the returned TData type; supply unmodified TData and use the third generic to specify allowed data states.
queryRefs created by preloadQuery no longer have a toPromise function; use preloadQuery.toPromise(queryRef).
Support for React 16 was dropped.
Calling refetch with new variables now sets networkStatus to refetch instead of setVariables.
reobserve is no longer available in the result returned from useLazyQuery because it was considered an internal API.
Mocked responses passed to MockLink accept a callback for request.variables; move the callback from variableMatcher to this field.
Resolver context now nests the request context under requestContext; read request-context properties from that key.
Resolver context now exposes client, requestContext, and phase; access the cache through client.cache.
Streaming no longer supports Node Streams, Async Iterators, or Blob response bodies; use a fetch implementation returning a WhatWG ReadableStream.
The deprecated resultCacheMaxSize option was removed from InMemoryCache options.
Calling retain on the promise returned by execute lets an in-flight query run to completion despite a later execution or component unmount.
rxjs replaces zen-observable for Apollo Client's observable implementation and is a new peer dependency to install.
RxJS is now a peer dependency and must be installed alongside Apollo Client and graphql.
The helper is no longer exported; JSON.stringify is used directly.
ServerError no longer parses response text as JSON; the raw response text is available as bodyText instead of the parsed result property.
Migrate from the setContext link to the SetContextLink class because the argument order changed.
The SetContextLink callback operation argument now uses this type, excludes getContext and setContext, and exposes client.
The callback arguments are now ordered prevContext, operation; the setContext function is unchanged.
This method for setting a fragment matcher after client initialization has been removed.
ApolloClient.setResolvers has been removed without a replacement.
Queries created with skipToken are excluded from refetchQueries until their first execution, when their variables are known.
The testing utility was removed from @apollo/client/testing.
Subscriptions now emit SubscribeResult instead of FetchResult, with error replacing errors.
The deprecated Subscription React component was removed; use the provided React hooks instead.
Network errors are subject to errorPolicy; terminating network errors are emitted on next's error property followed by complete.
Subscription errors are delivered on the result's error property in the next callback rather than the error callback; errors no longer automatically terminate an open connection.
With errorPolicy ignore, errors no longer emit a result when no data accompanies them.
Environments must support symbols; add appropriate polyfills where they are unavailable.
The ApolloClient constructor no longer accepts TCacheShape; remove the generic argument, and APIs that relied on it are now set to unknown.
The TContext and TCacheShape generics were removed; custom context types now use module augmentation.
The TData generic defaults to unknown across APIs that use it.
The zen-observable utility was removed; use RxJS firstValueFrom instead.
This utility is no longer exported from @apollo/client/link/utils; its work is incorporated into createOperation.
Apollo Client targets since 2023, node >= 20, not dead; projects targeting older environments may need to transpile the library or provide polyfills.
ApolloCache no longer accepts TSerialized; remove the generic argument, and APIs that relied on it are now set to unknown.
TVariables now always extends OperationVariables in all interfaces.
never is no longer a supported generic argument for APIs that require variables; use Record<string, never> instead.
The typeDefs option was removed from ApolloClient.
Local resolver objects and arrays for non-scalar fields must include __typename or the field becomes null and an error is added.
Aliasing another field to __typename is now forbidden.
GraphQL Codegen masked types require opting in through declaration merging; Apollo Client uses an identity type by default.
TypeScript variable requirements are stricter, return types are more precise, types are namespaced, and core types are customizable.
Non-string primitives and non-error-like objects thrown as errors are wrapped in UnconventionalError, with the original value available through cause.
The hook no longer accepts context; pass context to the execute function instead.
defaultOptions is no longer supported in useLazyQuery options; pass those options directly to the hook instead.
The deprecated errors property was removed; read errors from error instead.
The execute function only accepts variables and context, cannot be called during render or SSR, and in-flight queries are automatically cancelled when new ones start.
The execute promise now resolves to ApolloQueryResult and no longer includes all fields returned by the hook tuple.
Executing again rejects previously started queries from the same hook usage with AbortError unless retain() is called on their promises.
The execute promise rejects for GraphQL errors when errorPolicy is none.
initialFetchPolicy is no longer supported in useLazyQuery options; use fetchPolicy instead.
The first execute call no longer rerenders with loading state unless notifyOnNetworkStatusChange is true, which is the new default.
The onCompleted callback was removed from hook options; await the execute promise to perform side effects after completion.
The onError callback was removed from hook options; handle errors from the execute promise instead.
The hook no longer accepts variables; pass variables to the execute function instead.
useLazyQuery no longer accepts variables or context options; pass them to execute instead.
useLazyQuery no longer supports SSR and throws if execute is called during SSR; use useQuery for SSR queries.
After the first execution, option changes no longer trigger network requests; updated options take effect the next time execute is called.
The ignoreResults option was removed; use client.mutate directly when mutation results do not need to synchronize with component state.
The mutate function no longer accepts the mutation option.
React hook behavior and APIs change in Apollo Client 4; the migration notes identify useQuery among the affected hooks.
The called property was removed from useQuery.
Removes the defaultOptions option from useQuery; use options directly or ApolloClient global defaultOptions.
The deprecated errors property was removed; read errors from error instead.
The onCompleted callback option has been removed from useQuery.
The deprecated onCompleted and onError callbacks were removed.
The onCompleted callback was removed from useQuery and useLazyQuery.
The onError callback option has been removed from useQuery.
The onError callback was removed from useQuery and useLazyQuery.
useQuery no longer returns reobserve; rerender the hook with new options instead.
Most option changes on rerender no longer trigger reobserve or network fetches; query, variables, skip, and fetchPolicy changes to or from standby still do.
The deprecated callback was removed; use onComplete instead.
The deprecated callback was removed; use onData instead.
variables was removed from the result returned from useSubscription.
This utility is no longer exported from @apollo/client/link/utils; its work is incorporated into createOperation.
This option has been removed; pass its callback to request.variables instead.
Passing undefined for a variable replaces it with the query's default value when provided.
Environments must support WeakMap, WeakSet, and symbols; add appropriate polyfills where they are unavailable.
Environments must support WeakMap, WeakSet, and symbols; add appropriate polyfills where they are unavailable.
Apollo Client migrated from zen-observable to RxJS; transformations require pipe and RxJS operators replace method chaining.
Deprecations 20
The core entry point is equal to @apollo/client and is slated for removal in the next major; change imports to @apollo/client.
Provides the namespaced replacement for ApolloClientOptions; the old type remains available but is deprecated.
Provides the namespaced replacement for QueryOptions; the old type remains available but is deprecated.
The static method is deprecated in favor of ApolloLink.from, because it is now an alias for ApolloLink.from([a, b]).
Provides the namespaced replacement for FetchResult; the old type remains available but is deprecated.
The bare exported function is deprecated in favor of ApolloLink.concat().
The link creator remains available but is deprecated in favor of the HttpLink class.
The link creator remains available but is deprecated in favor of the PersistedQueryLink class.
The bare exported function is deprecated in favor of ApolloLink.empty().
The bare exported function is deprecated in favor of ApolloLink.from().
Generated hooks lack the function overloads needed for Apollo Client 4's improved hook type safety; the notes recommend using Apollo Client's hooks directly with TypedDocumentNode and migrating away from generated hooks.
Provides the namespaced replacement for ApolloQueryResult; the old type remains available but is deprecated.
The link creator remains available but is deprecated in favor of the ErrorLink class.
The link creator remains available but is deprecated in favor of the RemoveTypenameFromVariablesLink class.
A class-based replacement for removeTypenameFromVariables; the old link creator remains available but is deprecated.
The link creator remains available but is deprecated in favor of the SetContextLink class.
The bare exported function is deprecated in favor of ApolloLink.split().
Provides the namespaced replacement for LazyQueryResult; the old type remains available but is deprecated.
Provides the namespaced replacement for QueryHookOptions; the old type remains available but is deprecated.
Provides the namespaced replacement for QueryResult; the old type remains available but is deprecated.
New APIs and options 19
This entry point provides pre-compiled React hooks optimized by the React Compiler, with a runtime polyfill for React 17+.
Add incrementalHandler, configured with a Defer20220824Handler instance, to enable incremental delivery for @defer.
Static and instance concat methods now accept a dynamic number of link arguments, enabling concatenation of multiple links in one call.
Query results expose completeness states empty, partial, streaming, and complete for clearer loading distinctions and TypeScript narrowing.
Declaration merging with DefaultContext lets applications define custom context properties with type safety throughout Apollo Client APIs and links.
This incremental delivery handler supports the Apollo Router format.
The errors property provides access to raw protocol errors from a CombinedProtocolErrors instance.
A class-based replacement for createHttpLink; the old link creator remains available but is deprecated.
A specific error class is available for link-chain errors and can be checked with its is method.
Add resolvers after client initialization through the LocalState instance.
Validation failures throw LocalStateError; use LocalStateError.is to identify them and inspect their GraphQL document path.
A new network status is set while a deferred query response is streaming; loading remains true until streaming completes.
Exposes the GraphQL operation type directly on the operation, reducing the boilerplate needed to determine its type for routing.
The exports field defines available import paths, allowing package-root imports instead of paths such as @apollo/client/index.js or main.cjs.
A class-based replacement for createPersistedQueryLink; the old link creator remains available but is deprecated.
ServerParseError is now a proper error class and can be checked with its static is method.
TypeOverrides.signatureStyle can select modern or classic method and hook signatures; declaring a non-optional DeclareDefaultOptions property switches automatically to modern signatures.
A new type marks result data when dataState is streaming and can be overridden to integrate with different codegen dialects.
Module augmentation configures data masking types and incremental result types; multiple TypeOverrides can be combined.
Behavior and default changes 11
DiffResult is now a discriminated union; checking diff.complete narrows result to complete data or DeepPartial<T> | null.
The global remains a fallback for disabling development mode when build tooling does not support development or production export conditions.
Development mode is primarily selected by the package exports development condition, which modern bundlers should choose based on the build environment.
The error property is guaranteed to be an ErrorLike object with message and name properties; thrown non-error-like values are wrapped.
When true, extensions are still omitted from outgoing requests if extensions is unset or empty.
MockedProvider now uses realistic delays by default, between 20 and 50 milliseconds.
Calling refetch guarantees an observable emission, even when the value is deep equal to the previous value.
Calling setVariables with different variables guarantees an observable emission, even when the value is deep equal to the previous value.
More features are opt-in to reduce bundle size when they are not used.
ServerError is now a proper error class and can be checked with its static is method.
Network requests are initiated only when execute is called, so changing hook options does not cause unintended requests; new options apply on the next execution.
Tooling 1
A codemod package automates selected Apollo Client 3-to-4 migration changes; it can be run against project files or configured with options such as --codemod.
Fixes and other changes 13
Non-JSON-serializable custom scalar values are properly serialized when used as variables or key field values, allowing cache writes and cache.identify calls to succeed.
Custom scalar fields in subscription results are parsed when using the no-cache fetch policy.
A watch is unregistered when its immediate broadcast throws, preventing an unreachable failing watch from running on later broadcasts.
With Defer20220824Handler, dataState stays streaming when incremental errors occur instead of showing completed.
Fields whose @defer boundary has not been delivered from the network are no longer reported as missing when writing deferred results.
Selections of the same list field with different selection sets are now merged while a @defer boundary is pending, preserving fields included by only one selection.
Custom merge functions now receive streamFieldInfo for @stream directives with an aliased field in the path.
Fixes a memory leak in isDeferredFragment and isStreamField.
Responses with this content type are parsed as well-formed GraphQL responses even when the server returns a non-200 status code.
Mutations no longer report errors when the server's GraphQL result contains an empty errors array.
It now resolves with the last emitted result rather than undefined when variables match or the query has no subscribers.
ServerError and ServerParseError are now proper Error subclasses, so instanceof checks work correctly.
previousData advances only when data actually changes.