Change8

@apollo/client@4.0.0-rc.2

Breaking Changes
📦 apollo-client
2 breaking1 features🐛 2 fixes🔧 5 symbols

Summary

This release introduces a breaking change to `SetContextLink` callback parameters and operation type, adds overridable `DataValue` types for response states, and includes bug fixes for `operationType` propagation and `subscribeToMore` error typing.

⚠️ Breaking Changes

  • The `SetContextLink` callback signature was changed: the parameters are now `(prevContext, operation)` instead of `(operation, prevContext)`. Update all callbacks to use the new order.
  • The `operation` argument type for `SetContextLink` callbacks changed from `GraphQLRequest` to `SetContextLink.SetContextOperation`, which no longer provides `getContext` or `setContext`. Remove any usage of those methods and rely on the `prevContext` argument; the new `operation` includes a `client` property.

Migration Steps

  1. Change all `new SetContextLink` callback definitions to accept `(prevContext, operation)` instead of `(operation, prevContext)`.
  2. Replace any usage of `operation.getContext()` or `operation.setContext()` inside SetContextLink callbacks with the `prevContext` argument, as the `operation` argument no longer includes those methods.
  3. If you rely on the `operation` argument's type, import `SetContextLink.SetContextOperation` and adjust type annotations accordingly.
  4. Optionally, import and extend the `DataValue` namespace via module augmentation to customize `Complete`, `Streaming`, or `Partial` types.

✨ New Features

  • Added the `DataValue` namespace with `Complete`, `Streaming`, and `Partial` types to allow overriding the typings of `dataState: \"complete\"`, `\"streaming\"`, and `\"partial\"` responses.

🐛 Bug Fixes

  • Fixed a bug where the new `operationType` property was not being passed into the `operation` object.
  • Corrected the type of the `error` argument in the `onError` option for `subscribeToMore` to `ErrorLike`.

🔧 Affected Symbols

SetContextLinkSetContextLink.SetContextOperationDataValuesubscribeToMoreoperationType