Migrating to Apollo Client @apollo/client@4.0.0-rc.6
Version @apollo/client@4.0.0-rc.6 introduces 6 breaking changes. This guide details how to update your code.
Released: 7/28/2025
⚠️ Check Your Code
If you use any of these symbols, you need to read this guide:
DataProxyTVariablesuseMutationCache.ReadOptionsApolloConsumerApolloClientObservableQueryApolloCache.watchFragmentBreaking Changes
●Issue #1
Removed the `DataProxy` namespace and interface; imports referencing `DataProxy` must be removed or replaced with the new location.
●Issue #2
`TVariables` now always extends `OperationVariables` in all interfaces; code that defined `TVariables` without this constraint must be updated.
●Issue #3
The `mutation` option is no longer allowed for the `mutate` function returned from `useMutation`; callers must remove this option.
●Issue #4
The generic type parameters for `Cache.ReadOptions` were reordered from `<TVariables, TData>` to `<TData, TVariables>`; update all usages accordingly.
●Issue #5
`ApolloConsumer` component has been removed; replace it with the `useApolloClient` hook.
●Issue #6
Method options and result types for `ApolloClient`, `ObservableQuery`, and `ApolloCache.watchFragment` have been moved into dedicated namespaces; code importing the old types must be updated to the new namespace paths.
Migration Steps
- 1Remove all imports of `DataProxy` and update code to use the new APIs that replace its functionality.
- 2Ensure any custom `TVariables` types extend `OperationVariables` or adjust generic constraints accordingly.
- 3Delete the `mutation` field from options passed to the `mutate` function returned by `useMutation`.
- 4Update all `Cache.ReadOptions` usages to match the new generic order `<TData, TVariables>`.
- 5Replace any usage of the `ApolloConsumer` component with the `useApolloClient` hook.
- 6Import the moved types from their new namespaces (e.g., `ApolloClient.Options`, `ObservableQuery.Options`, `ApolloCache.WatchFragmentOptions`) and remove references to the deprecated exports.
Release Summary
The update removes the `DataProxy` namespace, flips generic type orders, disallows the `mutation` option in `useMutation`, deprecates old type exports, and removes `ApolloConsumer`, requiring code adjustments.
Need More Details?
View the full release notes and all changes for Apollo Client @apollo/client@4.0.0-rc.6.
View Full Changelog