Change8

@apollo/client@4.0.0-rc.1

Breaking Changes
📦 apollo-client
2 breaking5 features🐛 3 fixes🔧 9 symbols

Summary

This release removes two deprecated configuration options, adds a new `operationType` field for easier operation checks, exports several types, and includes bug fixes around resolver warnings and query rerendering.

⚠️ Breaking Changes

  • Removed deprecated `resultCacheMaxSize` option from `InMemoryCache` options; code that still sets this option will throw a configuration error. Remove the option from cache configuration.
  • Removed deprecated `connectToDevtools` option from `ApolloClientOptions`; replace it with `devtools.enabled` in the client options.

Migration Steps

  1. Remove any usage of `resultCacheMaxSize` from `InMemoryCache` configuration.
  2. Replace `connectToDevtools` in `ApolloClientOptions` with `devtools: { enabled: true/false }`.
  3. Update code that inspects operation type to use `operation.operationType` and compare against `OperationTypeNode` constants.
  4. Adjust TypeScript typings where `unsafePreviousData` is accessed; expect a `DeepPartial` shape instead of the full data type.
  5. Import `getMainDefinition` from `@apollo/client/utilities` if still needed; otherwise prefer the new `operation.operationType` approach.

✨ New Features

  • Added `operationType` property to the `operation` object in `ApolloLink`, allowing direct comparison with `OperationTypeNode` instead of using `getMainDefinition`.
  • Exported the `IgnoreModifier` type from `@apollo/client/cache`.
  • Changed the `unsafePreviousData` argument type on `UpdateQueryMapFn` and `SubscribeToMoreQueryFn` to `DeepPartial`, reflecting that the result may be partially populated.
  • Exported `getMainDefinition` from `@apollo/client/utilities` for easier import.
  • Improved `useQuery` to trigger a rerender when `notifyOnNetworkStatusChange` is `false` and a refetch with changed variables returns data that is deeply equal to previous variables.

🐛 Bug Fixes

  • Stopped warning about missing resolvers for `@client` fields that have no configured resolver, reducing confusion.
  • Ensured that `read` functions without a defined resolver receive `existing` as `null` (instead of `undefined`) to guarantee a field value presence.
  • Fixed `useQuery` rerender behavior when `notifyOnNetworkStatusChange` is `false` and a refetch returns a result deeply equal to previous variables.

🔧 Affected Symbols

InMemoryCacheApolloClientOptionsApolloLinkUpdateQueryMapFnSubscribeToMoreQueryFnIgnoreModifiergetMainDefinitionuseQueryLocalState.read