Change8

@apollo/client@4.0.0-alpha.16

Breaking Changes
📦 apollo-client
3 breaking3 features🔧 3 symbols

Summary

This release aligns Apollo Client with the GraphQL over HTTP spec by adding `application/graphql-response+json` support, changing error handling, and updating the default `Accept` header, while introducing breaking changes to `ServerError` and link notifications.

⚠️ Breaking Changes

  • The `result` property on `ServerError` was removed and replaced with `bodyText`. Code that accessed `error.result` must be updated to use `error.bodyText`.
  • `HttpLink` and `BatchHttpLink` no longer emit a `next` notification with the JSON‑parsed response body when a well‑formed GraphQL response is returned and a `ServerError` is thrown. Consumers that relied on that notification need to adjust their logic.
  • The default `Accept` header was changed to `application/graphql-response+json,application/json;q=0.9`, which may affect servers that expect the previous header value.

Migration Steps

  1. Replace any usage of `error.result` with `error.bodyText`.
  2. If your code relied on the `next` notification from `HttpLink` or `BatchHttpLink` when a `ServerError` occurs, modify it to handle the error via the error channel instead of the data channel.
  3. Review test utilities that mock HTTP responses; ensure they set the `content‑type` header to match production (e.g., `application/graphql-response+json`) to avoid differing behavior.
  4. If you set a custom `Accept` header, verify it still matches the server’s expectations after the default change.

✨ New Features

  • Added support for the `application/graphql-response+json` media type, aligning the client with the GraphQL over HTTP specification.
  • The client now throws a `ServerError` for non‑200 responses when the `content‑type` is `application/json` or any other type, providing stricter error handling.
  • Updated the default `Accept` header to prefer `application/graphql-response+json` over `application/json`.

🔧 Affected Symbols

ServerErrorHttpLinkBatchHttpLink