Change8

@apollo/client@4.1.0-alpha.1

📦 apollo-client
3 features🐛 2 fixes🔧 2 symbols

Summary

This release introduces an abstract `resolvesClientField` API, adds experimental feature support, and refines `@client` field handling, including warnings for `no-cache` queries.

Migration Steps

  1. Update any custom `read` functions for `@client` fields that relied on receiving `null` as the `existing` value; adjust them to handle `undefined` or provide default arguments.
  2. If you implement a custom cache, provide a `resolvesClientField` method on your `ApolloCache` implementation to correctly signal support for `@client` fields.
  3. Review queries using `no-cache` fetch policy and ensure a local resolver is defined for any `@client` fields, or expect a warning at runtime.

✨ New Features

  • Added abstract `resolvesClientField` function to `ApolloCache` allowing caches to indicate they can resolve a `@client` field without a local resolver.
  • Created a mechanism to add experimental features to Apollo Client.
  • Changed behavior so that when a `read` function is defined for a `@client` field, the fallback value is not set to `null`; the `read` function receives `existing` as `undefined` allowing default arguments.

🐛 Bug Fixes

  • LocalState no longer attempts to read from the cache when a query uses the `no-cache` fetch policy.
  • LocalState now emits a warning and does not silently ignore `@client` fields when a `no-cache` fetch policy is used without a local resolver.

🔧 Affected Symbols

ApolloCacheLocalState