unstale

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

@unstale/cli 0.2.8 on npm

@apollo/client 4329 changes

Breaking changes 265

  • The variables option is required when a fragment has required variables, matching useSuspenseFragment and the query hooks.

    4.3.5release notes

  • Field aliases beginning with __ac_ are forbidden because the namespace is reserved for internal use.

    4.0.0release notes

  • Outgoing requests now default to application/graphql-response+json,application/json;q=0.9 as the Accept header.

    4.0.0upgrade guiderelease notes

  • ApolloClient.addResolvers has been removed; add resolvers through the client's LocalState instance.

    4.0.0upgrade guiderelease notes

  • The core entry point is renamed to @apollo/client.

    4.0.0upgrade guide

  • The link/core entry point is renamed to @apollo/client/link.

    4.0.0upgrade guiderelease notes

  • React exports move from @apollo/client to @apollo/client/react, requiring React applications to update imports.

    4.0.0upgrade guiderelease notes

  • The render prop components entry point is removed in Apollo Client 4.

    4.0.0upgrade guide

  • This entry point was removed; use @apollo/client/react instead.

    4.0.0release notes

  • The higher order components entry point is removed in Apollo Client 4.

    4.0.0upgrade guide

  • The React hooks entry point is consolidated into @apollo/client/react.

    4.0.0upgrade guiderelease notes

  • The parser entry point is removed along with the render prop components and HOCs it implemented.

    4.0.0upgrade guiderelease notes

  • The testing/core entry point is renamed to @apollo/client/testing.

    4.0.0upgrade guide

  • The testing/core entrypoint is removed; import from @apollo/client/testing instead.

    4.0.0release notes

  • The experimental testing entry point is removed; the notes point to @apollo/graphql-testing-library as the available alternative.

    4.0.0upgrade guiderelease notes

  • Internal testing utilities moved here; utilities and types remaining at @apollo/client/testing are now considered stable.

    4.0.0release notes

  • MockedProvider moved from @apollo/client/testing to this entry point.

    4.0.0release notes

  • The utilities/globals entry point is removed as an implementation detail; some exports are available in other entry points.

    4.0.0upgrade guide

  • Most utilities moved to this entry point; utilities and types remaining at @apollo/client/utilities are documented and considered stable.

    4.0.0release notes

  • The urql subscriptions entry point is removed because urql supports this natively.

    4.0.0upgrade guiderelease notes

  • A type-only migration entry point provides doc blocks for removed exports; importing runtime values from it throws at runtime.

    4.0.0upgrade guide

  • The clientAwareness option now holds name and version, which move out of the top-level constructor options.

    4.0.0upgrade guiderelease notes

  • Move credentials from the ApolloClient constructor options to the link option, configuring them on an HttpLink instance.

    4.0.0upgrade guide

  • Certain default options cannot be passed to the constructor unless declared through DeclareDefaultOptions; other defaultOptions remain allowed.

    4.0.0upgrade guide

  • The connectToDevTools option is replaced by devtools, which contains an enabled property.

    4.0.0upgrade guide

  • Replace connectToDevTools with devtools.enabled to configure DevTools.

    4.0.0upgrade guiderelease notes

  • Move headers from the ApolloClient constructor options to the link option, configuring them on an HttpLink instance.

    4.0.0upgrade guide

  • Incremental delivery is configurable and requires an incremental handler; applications using @defer can provide Defer20220824Handler.

    4.0.0upgrade guiderelease notes

  • The link option is now required; ApolloClient no longer creates an implicit HttpLink.

    4.0.0release notes

  • Configure local state with a LocalState instance and move resolvers into that instance; typeDefs and fragmentMatcher options are removed.

    4.0.0upgrade guide

  • Rename disableNetworkFetches to prioritizeCacheValues.

    4.0.0upgrade guiderelease notes

  • Move uri from the ApolloClient constructor options to the link option, configuring it on an HttpLink instance.

    4.0.0upgrade guide

  • uri, headers, and credentials were removed from ApolloClient options; configure HttpLink directly.

    4.0.0release notes

  • 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.

    4.0.0upgrade guide

  • ObservableQueries are registered only while they have subscribers, so this method returns only queries with at least one subscriber.

    4.0.0release notes

  • The local resolvers API was removed from ApolloClient in favor of localState.

    4.0.0release notes

  • Provide a LocalState instance through this constructor option to enable local state management; using @client without it throws an error.

    4.0.0upgrade guiderelease notes

  • ApolloClientOptions is now named ApolloClient.Options; related ApolloClient types are namespaced under ApolloClient.

    4.0.0upgrade guide

  • Renames disableNetworkFetches; queries made while enabled apply a replacement fetch policy only for that request, without changing the ObservableQuery's original fetchPolicy.

    4.0.0release notes

  • Only queries with at least one subscriber can be returned or refetched; active and inactive query meanings also changed.

    4.0.0release notes

  • Removes the resolvers option; configure resolvers in a LocalState instance assigned to localState.

    4.0.0release notes

  • The resolvers constructor option has been removed; configure local resolvers on the LocalState instance instead.

    4.0.0upgrade guiderelease notes

  • The local resolvers API was removed from ApolloClient in favor of localState.

    4.0.0release notes

  • The local resolvers API was removed from ApolloClient in favor of localState.

    4.0.0release notes

  • stop() now unsubscribes active ObservableQuery instances, rejects in-flight queries, and removes queryRefs from the suspense cache.

    4.0.0release notes

  • ApolloConsumer has been removed; use useApolloClient instead.

    4.0.0release notes

  • The ApolloError class was removed; errors are no longer universally wrapped in this class.

    4.0.0upgrade guiderelease notes

  • Use the ApolloLink.concat static method instead of the concat function exported from @apollo/client/link.

    4.0.0upgrade guide

  • Use the ApolloLink.from static method instead of the from function exported from @apollo/client/link.

    4.0.0upgrade guide

  • The from, concat, and split static and instance methods now require ApolloLink instances; wrap request handler functions in an ApolloLink.

    4.0.0upgrade guide

  • A request handler must return an Observable; use RxJS EMPTY instead of null for an empty observable.

    4.0.0release notes

  • Use the ApolloLink.split static method instead of the split function exported from @apollo/client/link.

    4.0.0upgrade guide

  • execute now requires a third argument containing the client that initiated the request.

    4.0.0release notes

  • Removes the onError and setOnError methods from ApolloLink.

    4.0.0release notes

  • 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.

    4.0.0release notes

  • ApolloLink.Request no longer accepts operationName or operationType; those properties are derived from query and set on ApolloLink.Operation.

    4.0.0release notes

  • FetchResult is now ApolloLink.Result.

    4.0.0upgrade guide

  • Using an incremental delivery handler now requires explicitly opting into its chunk types through TypeOverrides module augmentation.

    4.0.0release notes

  • Properties such as called and refetch that are not included in ApolloQueryResult must be read from the hook instead.

    4.0.0release notes

  • The data field type is now TData | undefined, reflecting its possible runtime value.

    4.0.0release notes

  • Responses use the specification's application/json behavior; non-200 responses encoded as application/json or another content type now throw ServerError.

    4.0.0upgrade guide

  • A non-200 response with this content type now throws ServerError.

    4.0.0release notes

  • The utility was removed; use an RxJS operator such as from to create Observables from promises.

    4.0.0release notes

  • Removes the base React hook types; use the hook types instead.

    4.0.0release notes

  • includeExtensions now defaults to true; empty or unset extensions are not included in outgoing requests.

    4.0.0release notes

  • With no cached data, cache-only queries initialize with loading: false and NetworkStatus.ready.

    4.0.0release notes

  • Cache-only queries no longer poll; a warning is emitted, and changing to cache-only stops active polling.

    4.0.0release notes

  • 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.

    4.0.0release notes

  • With returnPartialData false and an incomplete result, cache.diff returns null instead of throwing; callers and cache implementations must check for or return null.

    4.0.0release notes

  • fragmentMatches is required, and data masking may crash if it is missing.

    4.0.0release notes

  • The generic arguments are now ordered TData, TVariables instead of TVariables, TData.

    4.0.0release notes

  • The option was removed because it caused memory leaks; object identity may differ for objects that were previously referentially equal.

    4.0.0upgrade guiderelease notes

  • client.mutate and useMutation now return MutateResult instead of FetchResult; errors are reported through error rather than errors.

    4.0.0release notes

  • client.query no longer supports fetchPolicy standby, which does not fetch or return data and is intended for watched queries.

    4.0.0release notes

  • Document transforms are applied before reading from the cache; use cache.readQuery to read without running transforms.

    4.0.0release notes

  • cache-only queries are no longer refetched when includeStandby is true.

    4.0.0release notes

  • Named queries in standby are now refetched; use onQueryUpdated to skip standby queries and retain v3 behavior.

    4.0.0upgrade guide

  • cache-only queries are excluded from refetchQueries in all situations, including updateCache effects when onQueryUpdated is absent.

    4.0.0release notes

  • Calling client.subscribe no longer eagerly starts a subscription; subscribe to the returned observable to start it.

    4.0.0release notes

  • The clientErrors property has no replacement; non-GraphQL and non-protocol errors are passed through as-is.

    4.0.0upgrade guide

  • ClientParseError was removed; JSON serialization errors are thrown directly.

    4.0.0release notes

  • GraphQL errors are represented by CombinedGraphQLErrors; use its is method to identify them and read the raw errors property.

    4.0.0upgrade guiderelease notes

  • Protocol errors are encapsulated in CombinedProtocolErrors; use its is method to check an error and read raw protocol errors from the errors property.

    4.0.0upgrade guide

  • concat, from, and split no longer accept a plain request handler function; wrap it with new ApolloLink.

    4.0.0release notes

  • Removes the deprecated ApolloClientOptions option; use devtools.enabled instead.

    4.0.0release notes

  • This testing utility has been removed; use MockLink directly with an ApolloClient instance.

    4.0.0upgrade guiderelease notes

  • createOperation now returns a well-formed Operation; callers should pass the request directly without transformOperation or validateOperation.

    4.0.0release notes

  • createOperation no longer accepts context as its first argument; put context on the request passed to createOperation.

    4.0.0release notes

  • disable and retry callbacks now receive a single error property instead of graphQLErrors and networkError.

    4.0.0release notes

  • The callback response property was renamed to result.

    4.0.0release notes

  • Applications using data masking need global type augmentation to enable data masking types when dataMasking is true.

    4.0.0upgrade guide

  • The DataMasking interface is no longer exported from @apollo/client or @apollo/client/masking.

    4.0.0release notes

  • The data masking types mode has been removed and the mode key has no effect; Masked and MaskedDocumentNode are also removed.

    4.0.0release notes

  • The DataProxy namespace and interface were removed.

    4.0.0release notes

  • TContext generic arguments were removed from types that used them and replaced with DefaultContext, which can be modified using declaration merging.

    4.0.0release notes

  • Applications using @defer need to enable incremental delivery and configure an incrementalHandler.

    4.0.0upgrade guide

  • HttpLink and BatchHttpLink now send client library name and version in extensions by default; disable transport awareness with enhancedClientAwareness: { transport: false }.

    4.0.0release notes

  • Errors from results are unified in the error property; remove checks for the errors property.

    4.0.0upgrade guide

  • Error handling uses a unified error property, granular error classes, and consistent errorPolicy behavior for all error types.

    4.0.0upgrade guide

  • A class-based replacement for onError; its callback receives a single error property instead of separate GraphQL, network, and protocol error properties.

    4.0.0upgrade guide

  • Network errors now follow errorPolicy: policies other than none resolve promises, while network-error data is undefined.

    4.0.0upgrade guide

  • 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.

    4.0.0release notes

  • Mutation network errors now follow errorPolicy: all resolves the promise and returns the error property, while none strips the error.

    4.0.0release notes

  • The execute function only accepts variables and context; other options must be provided to the hook, with changed values applied by rerendering before execution.

    4.0.0upgrade guiderelease notes

  • Calling execute during render now throws an error; use useQuery for queries that should execute during render.

    4.0.0upgrade guiderelease notes

  • 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.

    4.0.0upgrade guide

  • 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.

    4.0.0upgrade guide

  • Direct calls now require a third argument providing the ApolloClient instance that initiated the request.

    4.0.0upgrade guide

  • Export fields are validated before requests: they require a matching variable definition, and required variables cannot resolve to null or undefined.

    4.0.0upgrade guide

  • The package defines an exports field so bundlers resolve module formats through entry points instead of direct .js or .cjs imports.

    4.0.0upgrade guide

  • Calling fetchMore on a cache-only query now throws an error.

    4.0.0release notes

  • errorPolicy now defaults to none instead of being inherited, preventing accidental cache writes of partial paginated-query data.

    4.0.0release notes

  • When query is specified, unspecified options other than variables are inherited from the underlying ObservableQuery.

    4.0.0release notes

  • Without query, variables are shallowly merged with the underlying ObservableQuery variables; with query, fetchMore variables are used instead.

    4.0.0release notes

  • The ApolloClient fragmentMatcher option has been removed; fragment matching is now part of the cache through fragmentMatches.

    4.0.0upgrade guiderelease notes

  • Fragment matching is now a cache API; custom cache implementations used with LocalState must implement it.

    4.0.0upgrade guiderelease notes

  • Use the rxjs from function instead of Observable.from.

    4.0.0upgrade guide

  • The zen-observable utility was removed; use RxJS throwError instead.

    4.0.0upgrade guide

  • The zen-observable utility was removed; use RxJS from instead.

    4.0.0upgrade guiderelease notes

  • The context function for obtaining cache IDs has been removed; use operation.client.cache.identify instead.

    4.0.0upgrade guiderelease notes

  • ApolloClient.getResolvers has been removed without a replacement.

    4.0.0upgrade guide

  • Removes the deprecated graphql, withQuery, withMutation, withSubscription, and withApollo HOC components; use React hooks instead.

    4.0.0release notes

  • graphql v15 is no longer a valid peer dependency.

    4.0.0release notes

  • The TVariables generic argument was removed from GraphQLRequest.

    4.0.0release notes

  • An error is thrown if the connection closes before the final boundary; data after the final boundary is ignored.

    4.0.0release notes

  • Apollo-provided createHttpLink usage migrates to the HttpLink class, instantiated with new.

    4.0.0upgrade guide

  • includeExtensions now defaults to true; empty or unset extensions are not included in outgoing requests.

    4.0.0release notes

  • Create and pass an HttpLink through ApolloClient's link option; the uri, headers, and credentials constructor options no longer implicitly create one.

    4.0.0upgrade guiderelease notes

  • The resetResultIdentities option was removed because object canonization was removed.

    4.0.0release notes

  • The utility was removed; check for the specific error types that replace ApolloError.

    4.0.0release notes

  • A synchronous link-chain response omits the loading state; an asynchronous response triggers it.

    4.0.0release notes

  • Thrown local resolver errors are added to the GraphQL response errors array and the field value is set to null.

    4.0.0upgrade guide

  • Resolvers must return a value or null; undefined becomes null and logs a warning, except for exported-variable resolution.

    4.0.0upgrade guide

  • Local state is opt-in: create a LocalState instance and pass it as ApolloClient's localState option; move local resolvers into its constructor.

    4.0.0upgrade guiderelease notes

  • A client-only query in a mocked response now throws an error.

    4.0.0release notes

  • Mocks without a specified delay now use a random realistic delay between 20 and 50ms; set delay to 0 to restore no delay.

    4.0.0upgrade guiderelease notes

  • This testing utility was removed; use MockSubscriptionLink instead.

    4.0.0release notes

  • This testing utility was removed; use MockLink instead.

    4.0.0release notes

  • The deprecated Mutation React component was removed; use the provided React hooks instead.

    4.0.0release notes

  • Network errors are returned as-is rather than wrapped; use the error property directly.

    4.0.0upgrade guide

  • The newData option was removed from MockLink and MockedProvider mocks; use result as a callback with maxUsageCount set to Number.POSITIVE_INFINITY.

    4.0.0release notes

  • 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.

    4.0.0upgrade guiderelease notes

  • This is the default incremental delivery handler and throws if @defer is used.

    4.0.0release notes

  • Observable instances now use rxjs, so instance methods such as map, filter, reduce, flatMap, and concat must be replaced with rxjs equivalents.

    4.0.0upgrade guide

  • When cache data cannot fulfill a query, its first emitted result is now a loading state.

    4.0.0upgrade guide

  • Previous data is retained during loading emissions unless the query or variables changed.

    4.0.0release notes

  • Removes errors from ObservableQuery results and client.query results; read errors from error instead.

    4.0.0release notes

  • With fetchPolicy set to standby, ObservableQuery returns loading: false even before subscription.

    4.0.0release notes

  • The saveAsLastResult argument has been dropped.

    4.0.0release notes

  • Removes getLastResult, getLastError, and resetLastResults from ObservableQuery.

    4.0.0release notes

  • Removes queryId from ObservableQuery; getObservableQueries now returns a Set rather than a Map.

    4.0.0release notes

  • ObservableQuery.result() was removed; use RxJS firstValueFrom with the observable instead.

    4.0.0release notes

  • setOptions was removed as an alias of reobserve; use reobserve directly, which is now public.

    4.0.0release notes

  • Calling reobserve with variables: undefined resets variables to empty instead of leaving them unchanged.

    4.0.0release notes

  • The client tracks ObservableQuery instances only while they have subscribers, changing which queries client APIs consider active or inactive and avoiding unnecessary refetches.

    4.0.0upgrade guide

  • ObservableQuery no longer inherits from Observable; use RxJS from when an API requires an Observable. It still supports subscribe and pipe.

    4.0.0upgrade guide

  • Network errors no longer emit an error notification or terminate observables; read errors from result.error in the next callback.

    4.0.0upgrade guiderelease notes

  • Unsubscribing while a request is in flight no longer terminates the request by unsubscribing from the link observable.

    4.0.0release notes

  • Unsubscribing before the first value removes the query from the tracked query list, making it ineligible for query deduplication.

    4.0.0release notes

  • When notifyOnNetworkStatusChange is true, subscribing emits an initial loading state.

    4.0.0release notes

  • Use the rxjs of function instead of Observable.of.

    4.0.0upgrade guide

  • The link callback now reports the cause through a single error property instead of separate GraphQL, network, and protocol error properties.

    4.0.0release notes

  • The response property in the onError link has been renamed to result.

    4.0.0release notes

  • Links can access the ApolloClient instance that initiated the request, including its cache.

    4.0.0upgrade guide

  • The returned context object is now frozen and Readonly. Use operation.setContext() to make changes so they propagate to downstream links.

    4.0.0upgrade guiderelease notes

  • The cache property has been removed from operation context; access the cache through operation.client.cache instead.

    4.0.0upgrade guiderelease notes

  • The forceFetch context property is removed and replaced by queryDeduplication, which indicates whether deduplication was enabled for the request.

    4.0.0release notes

  • The property is now a non-null OperationTypeNode and can be compared without checking for undefined.

    4.0.0release notes

  • Use this method to change operation context now that the object returned by operation.getContext() is frozen and Readonly.

    4.0.0upgrade guide

  • OperationBatcher is no longer exported from @apollo/client/link/batch and should not be used directly.

    4.0.0release notes

  • Anonymous queries now set operationName to undefined rather than an empty string; check for undefined before using string methods.

    4.0.0upgrade guiderelease notes

  • The package now exposes entry points through the root package.json exports field; proxy-directory package.json files were removed.

    4.0.0release notes

  • The deprecated partialRefetch option was removed.

    4.0.0release notes

  • Apollo Client has stopped shipping polyfills; older browsers or special environments may need their own polyfills.

    4.0.0upgrade guide

  • toPromise moved from queryRef to the preloadQuery function; pass the queryRef to preloadQuery.toPromise, making queryRef objects more serializable for SSR.

    4.0.0upgrade guiderelease notes

  • This SSR API replaces deprecated SSR functions and works with React 19 prerender APIs.

    4.0.0release notes

  • In useLazyQuery, previousData changes only when data changes; it no longer changes to the same value as data while loading.

    4.0.0release notes

  • Apollo Client defaults to production rather than development when the environment cannot be determined or globalThis.__DEV__ is not true.

    4.0.0release notes

  • The loading property was removed from promise-based query API results because promise resolution guarantees the query is no longer loading.

    4.0.0release notes

  • The networkStatus property was removed from promise-based query API results.

    4.0.0release notes

  • The partial property was removed from promise-based query API results.

    4.0.0release notes

  • Queries and mutations now throw an error if the link chain completes without emitting a value.

    4.0.0release notes

  • The deprecated Query React component was removed; use the provided React hooks instead.

    4.0.0release notes

  • Subscriptions are deduplicated by default when they qualify; set queryDeduplication to false in the subscription context to create a separate connection.

    4.0.0upgrade guide

  • The QueryReference type is renamed QueryRef.

    4.0.0upgrade guiderelease notes

  • DataState now modifies the returned TData type; supply unmodified TData and use the third generic to specify allowed data states.

    4.0.0release notes

  • queryRefs created by preloadQuery no longer have a toPromise function; use preloadQuery.toPromise(queryRef).

    4.0.0release notes

  • Support for React 16 was dropped.

    4.0.0release notes

  • Calling refetch with new variables now sets networkStatus to refetch instead of setVariables.

    4.0.0release notes

  • reobserve is no longer available in the result returned from useLazyQuery because it was considered an internal API.

    4.0.0release notes

  • Mocked responses passed to MockLink accept a callback for request.variables; move the callback from variableMatcher to this field.

    4.0.0release notes

  • Resolver context now nests the request context under requestContext; read request-context properties from that key.

    4.0.0upgrade guide

  • Resolver context now exposes client, requestContext, and phase; access the cache through client.cache.

    4.0.0release notes

  • Streaming no longer supports Node Streams, Async Iterators, or Blob response bodies; use a fetch implementation returning a WhatWG ReadableStream.

    4.0.0release notes

  • The deprecated resultCacheMaxSize option was removed from InMemoryCache options.

    4.0.0release notes

  • Calling retain on the promise returned by execute lets an in-flight query run to completion despite a later execution or component unmount.

    4.0.0upgrade guide

  • rxjs replaces zen-observable for Apollo Client's observable implementation and is a new peer dependency to install.

    4.0.0upgrade guiderelease notes

  • RxJS is now a peer dependency and must be installed alongside Apollo Client and graphql.

    4.0.0release notes

  • The helper is no longer exported; JSON.stringify is used directly.

    4.0.0release notes

  • ServerError no longer parses response text as JSON; the raw response text is available as bodyText instead of the parsed result property.

    4.0.0upgrade guiderelease notes

  • Migrate from the setContext link to the SetContextLink class because the argument order changed.

    4.0.0upgrade guide

  • The SetContextLink callback operation argument now uses this type, excludes getContext and setContext, and exposes client.

    4.0.0release notes

  • The callback arguments are now ordered prevContext, operation; the setContext function is unchanged.

    4.0.0release notes

  • This method for setting a fragment matcher after client initialization has been removed.

    4.0.0upgrade guide

  • ApolloClient.setResolvers has been removed without a replacement.

    4.0.0upgrade guide

  • Queries created with skipToken are excluded from refetchQueries until their first execution, when their variables are known.

    4.0.0upgrade guide

  • The testing utility was removed from @apollo/client/testing.

    4.0.0release notes

  • Subscriptions now emit SubscribeResult instead of FetchResult, with error replacing errors.

    4.0.0release notes

  • The deprecated Subscription React component was removed; use the provided React hooks instead.

    4.0.0release notes

  • Network errors are subject to errorPolicy; terminating network errors are emitted on next's error property followed by complete.

    4.0.0release notes

  • 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.

    4.0.0release notes

  • With errorPolicy ignore, errors no longer emit a result when no data accompanies them.

    4.0.0release notes

  • Environments must support symbols; add appropriate polyfills where they are unavailable.

    4.0.0release notes

  • The ApolloClient constructor no longer accepts TCacheShape; remove the generic argument, and APIs that relied on it are now set to unknown.

    4.0.0upgrade guiderelease notes

  • The TContext and TCacheShape generics were removed; custom context types now use module augmentation.

    4.0.0release notes

  • The TData generic defaults to unknown across APIs that use it.

    4.0.0release notes

  • The zen-observable utility was removed; use RxJS firstValueFrom instead.

    4.0.0upgrade guide

  • This utility is no longer exported from @apollo/client/link/utils; its work is incorporated into createOperation.

    4.0.0release notes

  • Apollo Client targets since 2023, node >= 20, not dead; projects targeting older environments may need to transpile the library or provide polyfills.

    4.0.0upgrade guide

  • ApolloCache no longer accepts TSerialized; remove the generic argument, and APIs that relied on it are now set to unknown.

    4.0.0upgrade guiderelease notes

  • TVariables now always extends OperationVariables in all interfaces.

    4.0.0release notes

  • never is no longer a supported generic argument for APIs that require variables; use Record<string, never> instead.

    4.0.0release notes

  • The typeDefs option was removed from ApolloClient.

    4.0.0release notes

  • Local resolver objects and arrays for non-scalar fields must include __typename or the field becomes null and an error is added.

    4.0.0upgrade guide

  • Aliasing another field to __typename is now forbidden.

    4.0.0release notes

  • GraphQL Codegen masked types require opting in through declaration merging; Apollo Client uses an identity type by default.

    4.0.0release notes

  • TypeScript variable requirements are stricter, return types are more precise, types are namespaced, and core types are customizable.

    4.0.0upgrade guide

  • Non-string primitives and non-error-like objects thrown as errors are wrapped in UnconventionalError, with the original value available through cause.

    4.0.0upgrade guiderelease notes

  • The hook no longer accepts context; pass context to the execute function instead.

    4.0.0upgrade guiderelease notes

  • defaultOptions is no longer supported in useLazyQuery options; pass those options directly to the hook instead.

    4.0.0release notes

  • The deprecated errors property was removed; read errors from error instead.

    4.0.0release notes

  • 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.

    4.0.0release notes

  • The execute promise now resolves to ApolloQueryResult and no longer includes all fields returned by the hook tuple.

    4.0.0release notes

  • Executing again rejects previously started queries from the same hook usage with AbortError unless retain() is called on their promises.

    4.0.0release notes

  • The execute promise rejects for GraphQL errors when errorPolicy is none.

    4.0.0release notes

  • initialFetchPolicy is no longer supported in useLazyQuery options; use fetchPolicy instead.

    4.0.0release notes

  • The first execute call no longer rerenders with loading state unless notifyOnNetworkStatusChange is true, which is the new default.

    4.0.0release notes

  • The onCompleted callback was removed from hook options; await the execute promise to perform side effects after completion.

    4.0.0upgrade guide

  • The onError callback was removed from hook options; handle errors from the execute promise instead.

    4.0.0upgrade guide

  • The hook no longer accepts variables; pass variables to the execute function instead.

    4.0.0upgrade guiderelease notes

  • useLazyQuery no longer accepts variables or context options; pass them to execute instead.

    4.0.0release notes

  • useLazyQuery no longer supports SSR and throws if execute is called during SSR; use useQuery for SSR queries.

    4.0.0release notes

  • After the first execution, option changes no longer trigger network requests; updated options take effect the next time execute is called.

    4.0.0release notes

  • The ignoreResults option was removed; use client.mutate directly when mutation results do not need to synchronize with component state.

    4.0.0upgrade guide

  • The mutate function no longer accepts the mutation option.

    4.0.0release notes

  • React hook behavior and APIs change in Apollo Client 4; the migration notes identify useQuery among the affected hooks.

    4.0.0upgrade guide

  • The called property was removed from useQuery.

    4.0.0release notes

  • Removes the defaultOptions option from useQuery; use options directly or ApolloClient global defaultOptions.

    4.0.0release notes

  • The deprecated errors property was removed; read errors from error instead.

    4.0.0release notes

  • The onCompleted callback option has been removed from useQuery.

    4.0.0upgrade guide

  • The deprecated onCompleted and onError callbacks were removed.

    4.0.0release notes

  • The onCompleted callback was removed from useQuery and useLazyQuery.

    4.0.0release notes

  • The onError callback option has been removed from useQuery.

    4.0.0upgrade guide

  • The onError callback was removed from useQuery and useLazyQuery.

    4.0.0release notes

  • useQuery no longer returns reobserve; rerender the hook with new options instead.

    4.0.0release notes

  • Most option changes on rerender no longer trigger reobserve or network fetches; query, variables, skip, and fetchPolicy changes to or from standby still do.

    4.0.0release notes

  • The deprecated callback was removed; use onComplete instead.

    4.0.0release notes

  • The deprecated callback was removed; use onData instead.

    4.0.0release notes

  • variables was removed from the result returned from useSubscription.

    4.0.0release notes

  • This utility is no longer exported from @apollo/client/link/utils; its work is incorporated into createOperation.

    4.0.0release notes

  • This option has been removed; pass its callback to request.variables instead.

    4.0.0release notes

  • Passing undefined for a variable replaces it with the query's default value when provided.

    4.0.0release notes

  • Environments must support WeakMap, WeakSet, and symbols; add appropriate polyfills where they are unavailable.

    4.0.0release notes

  • Environments must support WeakMap, WeakSet, and symbols; add appropriate polyfills where they are unavailable.

    4.0.0release notes

  • Apollo Client migrated from zen-observable to RxJS; transformations require pipe and RxJS operators replace method chaining.

    4.0.0release notes

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.

    4.0.0release notes

  • Provides the namespaced replacement for ApolloClientOptions; the old type remains available but is deprecated.

    4.0.0upgrade guide

  • Provides the namespaced replacement for QueryOptions; the old type remains available but is deprecated.

    4.0.0upgrade guide

  • The static method is deprecated in favor of ApolloLink.from, because it is now an alias for ApolloLink.from([a, b]).

    4.0.0upgrade guide

  • Provides the namespaced replacement for FetchResult; the old type remains available but is deprecated.

    4.0.0upgrade guide

  • The bare exported function is deprecated in favor of ApolloLink.concat().

    4.0.0upgrade guide

  • The link creator remains available but is deprecated in favor of the HttpLink class.

    4.0.0upgrade guiderelease notes

  • The link creator remains available but is deprecated in favor of the PersistedQueryLink class.

    4.0.0upgrade guiderelease notes

  • The bare exported function is deprecated in favor of ApolloLink.empty().

    4.0.0upgrade guide

  • The bare exported function is deprecated in favor of ApolloLink.from().

    4.0.0upgrade guide

  • 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.

    4.0.0upgrade guide

  • Provides the namespaced replacement for ApolloQueryResult; the old type remains available but is deprecated.

    4.0.0upgrade guide

  • The link creator remains available but is deprecated in favor of the ErrorLink class.

    4.0.0upgrade guide

  • The link creator remains available but is deprecated in favor of the RemoveTypenameFromVariablesLink class.

    4.0.0upgrade guiderelease notes

  • A class-based replacement for removeTypenameFromVariables; the old link creator remains available but is deprecated.

    4.0.0upgrade guide

  • The link creator remains available but is deprecated in favor of the SetContextLink class.

    4.0.0upgrade guiderelease notes

  • The bare exported function is deprecated in favor of ApolloLink.split().

    4.0.0upgrade guide

  • Provides the namespaced replacement for LazyQueryResult; the old type remains available but is deprecated.

    4.0.0upgrade guide

  • Provides the namespaced replacement for QueryHookOptions; the old type remains available but is deprecated.

    4.0.0upgrade guide

  • Provides the namespaced replacement for QueryResult; the old type remains available but is deprecated.

    4.0.0upgrade guide

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+.

    4.0.0release notes

  • Add incrementalHandler, configured with a Defer20220824Handler instance, to enable incremental delivery for @defer.

    4.0.0upgrade guide

  • Static and instance concat methods now accept a dynamic number of link arguments, enabling concatenation of multiple links in one call.

    4.0.0upgrade guide

  • Query results expose completeness states empty, partial, streaming, and complete for clearer loading distinctions and TypeScript narrowing.

    4.0.0release notes

  • Declaration merging with DefaultContext lets applications define custom context properties with type safety throughout Apollo Client APIs and links.

    4.0.0upgrade guide

  • This incremental delivery handler supports the Apollo Router format.

    4.0.0release notes

  • The errors property provides access to raw protocol errors from a CombinedProtocolErrors instance.

    4.0.0upgrade guide

  • A class-based replacement for createHttpLink; the old link creator remains available but is deprecated.

    4.0.0upgrade guide

  • A specific error class is available for link-chain errors and can be checked with its is method.

    4.0.0release notes

  • Add resolvers after client initialization through the LocalState instance.

    4.0.0upgrade guide

  • Validation failures throw LocalStateError; use LocalStateError.is to identify them and inspect their GraphQL document path.

    4.0.0upgrade guide

  • A new network status is set while a deferred query response is streaming; loading remains true until streaming completes.

    4.0.0release notes

  • Exposes the GraphQL operation type directly on the operation, reducing the boilerplate needed to determine its type for routing.

    4.0.0upgrade guide

  • The exports field defines available import paths, allowing package-root imports instead of paths such as @apollo/client/index.js or main.cjs.

    4.0.0upgrade guide

  • A class-based replacement for createPersistedQueryLink; the old link creator remains available but is deprecated.

    4.0.0upgrade guide

  • ServerParseError is now a proper error class and can be checked with its static is method.

    4.0.0upgrade guiderelease notes

  • TypeOverrides.signatureStyle can select modern or classic method and hook signatures; declaring a non-optional DeclareDefaultOptions property switches automatically to modern signatures.

    4.0.0upgrade guide

  • A new type marks result data when dataState is streaming and can be overridden to integrate with different codegen dialects.

    4.0.0release notes

  • Module augmentation configures data masking types and incremental result types; multiple TypeOverrides can be combined.

    4.0.0upgrade guide

Behavior and default changes 11

  • DiffResult is now a discriminated union; checking diff.complete narrows result to complete data or DeepPartial<T> | null.

    4.0.0release notes

  • The global remains a fallback for disabling development mode when build tooling does not support development or production export conditions.

    4.0.0upgrade guide

  • Development mode is primarily selected by the package exports development condition, which modern bundlers should choose based on the build environment.

    4.0.0upgrade guide

  • The error property is guaranteed to be an ErrorLike object with message and name properties; thrown non-error-like values are wrapped.

    4.0.0upgrade guide

  • When true, extensions are still omitted from outgoing requests if extensions is unset or empty.

    4.0.0release notes

  • MockedProvider now uses realistic delays by default, between 20 and 50 milliseconds.

    4.0.0release notes

  • Calling refetch guarantees an observable emission, even when the value is deep equal to the previous value.

    4.0.0release notes

  • Calling setVariables with different variables guarantees an observable emission, even when the value is deep equal to the previous value.

    4.0.0release notes

  • More features are opt-in to reduce bundle size when they are not used.

    4.0.0upgrade guide

  • ServerError is now a proper error class and can be checked with its static is method.

    4.0.0upgrade guide

  • 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.

    4.0.0upgrade guide

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.

    4.0.0upgrade guide

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.

    4.3.5release notes

  • Custom scalar fields in subscription results are parsed when using the no-cache fetch policy.

    4.3.5release notes

  • A watch is unregistered when its immediate broadcast throws, preventing an unreachable failing watch from running on later broadcasts.

    4.3.4release notes

  • With Defer20220824Handler, dataState stays streaming when incremental errors occur instead of showing completed.

    4.3.4release notes

  • Fields whose @defer boundary has not been delivered from the network are no longer reported as missing when writing deferred results.

    4.3.4release notes

  • 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.

    4.3.4release notes

  • Custom merge functions now receive streamFieldInfo for @stream directives with an aliased field in the path.

    4.3.4release notes

  • Fixes a memory leak in isDeferredFragment and isStreamField.

    4.3.3release notes

  • Responses with this content type are parsed as well-formed GraphQL responses even when the server returns a non-200 status code.

    4.0.0release notes

  • Mutations no longer report errors when the server's GraphQL result contains an empty errors array.

    4.0.0release notes

  • It now resolves with the last emitted result rather than undefined when variables match or the query has no subscribers.

    4.0.0release notes

  • ServerError and ServerParseError are now proper Error subclasses, so instanceof checks work correctly.

    4.0.0release notes

  • previousData advances only when data actually changes.

    4.0.0release notes