Change8

@apollo/client@4.0.0-rc.6

Breaking Changes
📦 apollo-client
6 breaking1 deprecations🔧 8 symbols

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.

⚠️ Breaking Changes

  • Removed the `DataProxy` namespace and interface; imports referencing `DataProxy` must be removed or replaced with the new location.
  • `TVariables` now always extends `OperationVariables` in all interfaces; code that defined `TVariables` without this constraint must be updated.
  • The `mutation` option is no longer allowed for the `mutate` function returned from `useMutation`; callers must remove this option.
  • The generic type parameters for `Cache.ReadOptions` were reordered from `<TVariables, TData>` to `<TData, TVariables>`; update all usages accordingly.
  • `ApolloConsumer` component has been removed; replace it with the `useApolloClient` hook.
  • 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

  1. Remove all imports of `DataProxy` and update code to use the new APIs that replace its functionality.
  2. Ensure any custom `TVariables` types extend `OperationVariables` or adjust generic constraints accordingly.
  3. Delete the `mutation` field from options passed to the `mutate` function returned by `useMutation`.
  4. Update all `Cache.ReadOptions` usages to match the new generic order `<TData, TVariables>`.
  5. Replace any usage of the `ApolloConsumer` component with the `useApolloClient` hook.
  6. Import the moved types from their new namespaces (e.g., `ApolloClient.Options`, `ObservableQuery.Options`, `ApolloCache.WatchFragmentOptions`) and remove references to the deprecated exports.

🔧 Affected Symbols

DataProxyTVariablesuseMutationCache.ReadOptionsApolloConsumerApolloClientObservableQueryApolloCache.watchFragment

⚡ Deprecations

  • Old type exports for `ApolloClient`, `ObservableQuery`, and `ApolloCache.watchFragment` are now deprecated; migrate to the new namespace exports.