Change8

@apollo/client@4.0.0-rc.8

Breaking Changes
📦 apollo-clientView on GitHub →
6 breaking7 features🐛 2 fixes1 deprecations🔧 13 symbols

Summary

This release removes exported helpers, tightens type definitions, moves link types into a namespace, and updates RetryLink behavior, introducing breaking changes that require code adjustments.

⚠️ Breaking Changes

  • The `serializeFetchParameter` helper is no longer exported; callers must replace it with `stringify` directly.
  • `ClientParseError` type has been removed; JSON serialization errors are now thrown as generic errors.
  • `OperationBatcher` class is no longer exported from `@apollo/client/link/batch`; code that imported it will break.
  • `HttpLink.Options.fetchOptions` and the `fetchOptions` option for `BatchHttpLink` now require a `RequestInit` object instead of `any`, causing type errors for previous usages.
  • `credentials` option on `HttpLink`/`BatchHttpLink` now expects a `RequestCredentials` type instead of a plain string.
  • The `error` argument for `delay` and `attempts` functions on `RetryLink` must now be an `ErrorLike` object, breaking code that passed other types.

Migration Steps

  1. Replace any import of `serializeFetchParameter` with direct calls to `stringify`.
  2. Remove imports of `ClientParseError`; handle JSON serialization errors using generic `Error` handling.
  3. Stop importing `OperationBatcher` from `@apollo/client/link/batch`; rely on `BatchLink` internal implementation.
  4. Update code that passes `fetchOptions` to `HttpLink` or `BatchHttpLink` to provide a `RequestInit` object.
  5. Change any string literals used for the `credentials` option to the appropriate `RequestCredentials` enum values (`'omit'`, `'same-origin'`, `'include'`).
  6. Ensure that the `error` argument passed to `delay` and `attempts` on `RetryLink` conforms to the `ErrorLike` interface.
  7. Pass a string to the `sha256` function of `PersistedQueryLink` instead of an array or other types.

✨ New Features

  • All first‑party link types have been moved into a dedicated namespace.
  • `RetryLink` now emits a `next` event instead of an `error` event when a multipart subscription encounters a protocol error and the operation is not retried.
  • `delay` and `attempts` functions on `RetryLink` now enforce that the `error` argument is an `ErrorLike`.
  • `HttpLink.Options.fetchOptions` type updated to `RequestInit`.
  • `fetchOptions` option for `BatchHttpLink` updated to `RequestInit`.
  • `credentials` option type updated to `RequestCredentials`.
  • `sha256` function for `PersistedQueryLink` now accepts a `string` argument instead of `...any[]`.

🐛 Bug Fixes

  • Fixed `RetryLink` behavior to emit a `next` event for protocol errors, preserving observable semantics.
  • Corrected the type of the argument for `sha256` in `PersistedQueryLink` from `...any[]` to `string`.

🔧 Affected Symbols

serializeFetchParameterClientParseErrorOperationBatcherRetryLinkdelayattemptsHttpLinkBatchHttpLinkHttpLink.Options.fetchOptionscredentialssha256PersistedQueryLinkWebSocketLink

⚡ Deprecations

  • `WebSocketLink` now emits a deprecation warning.