Change8

@apollo/client@4.0.0-alpha.22

Breaking Changes
📦 apollo-client
5 breaking4 features🐛 1 fixes🔧 8 symbols

Summary

This release introduces enhanced client awareness, changes default behaviors for extensions and multipart Accept headers, adds new link utilities, and enforces stricter alias rules, along with a bug fix for persisted queries.

⚠️ Breaking Changes

  • The `includeExtensions` option of `HttpLink` and `BatchHttpLink` now defaults to `true`, which may cause extensions to be sent unintentionally. To retain previous behavior set `includeExtensions: false` in the link options.
  • `ApolloClient` constructor options `name` and `version` have been moved under a `clientAwareness` key; update client initialization accordingly.
  • Aliasing any field to `__typename` is now forbidden; rename such aliases to a non‑reserved name.
  • Aliasing a field to an alias that starts with `__ac_` is now forbidden; avoid using that prefix.
  • The default `Accept` header for multipart requests has changed to include `application/graphql-response+json` and a lower‑priority `application/json`; adjust server expectations or override the header if needed.

Migration Steps

  1. Set `includeExtensions: false` on `HttpLink`/`BatchHttpLink` if you relied on the previous default of false.
  2. Move `name` and `version` options into a `clientAwareness` object when constructing `ApolloClient`.
  3. Review GraphQL queries and remove any alias to `__typename` or aliases beginning with `__ac_`.
  4. If your server expects the old multipart `Accept` header, override it via the new `accept` option or adjust the server to accept the new header format.
  5. To keep bundle size minimal, replace `HttpLink`/`BatchHttpLink` with `BaseHttpLink`/`BaseBatchHttpLink` if you do not need client awareness features.

✨ New Features

  • `ClientAwarenessLink` added and automatically included in `HttpLink` and `BatchHttpLink` to provide client awareness data.
  • Enhanced client awareness sends `clientLibrary` information in request extensions by default; can be disabled via `enhancedClientAwareness: { transport: false }`.
  • New `accept` option on `HttpOptions` to merge additional Accept headers without overriding defaults.
  • `BaseHttpLink` and `BaseBatchHttpLink` provided as lighter alternatives without the built‑in `ClientAwarenessLink`.

🐛 Bug Fixes

  • Fixed bug in `PersistedQueryLink` where the `persistedQuery` extension was still sent after a `PersistedQueryNotSupported` response when `includeExtensions` was enabled on `HttpLink`.

🔧 Affected Symbols

HttpLinkBatchHttpLinkApolloClientPersistedQueryLinkClientAwarenessLinkBaseHttpLinkBaseBatchHttpLinkHttpOptions