Change8

@apollo/client@4.1.0-rc.0

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

Summary

Added stream‑info handling improvements, exposed a new type for cache extensions, and fixed redundant merge calls, with a breaking change affecting the legacy `Defer20220824Handler`.

⚠️ Breaking Changes

  • The default stream merge function is now applied to `@stream` fields only when stream info is present. The older `Defer20220824Handler` will no longer use the default merge function and will truncate the streamed array on the first chunk. Update handlers or provide stream info to avoid truncation.

Migration Steps

  1. If you use `Defer20220824Handler`, verify that stream info is provided; otherwise the streamed array will be truncated on the first chunk. Consider switching to a handler that supplies stream info or adjust your logic accordingly.
  2. Import and use the new `ExtensionsWithStreamInfo` type when working with `Cache.writeQuery`, `Cache.write`, or `Cache.update` if you need to access stream information in custom cache implementations.
  3. No code changes are required to benefit from the `WeakRef` delivery of `streamInfo` unless you directly manipulate the extensions object.

✨ New Features

  • Expose the `ExtensionsWithStreamInfo` type for the `extensions` option in `Cache.writeQuery`, `Cache.write`, and `Cache.update` so custom cache implementations can access stream info.
  • Pass `streamInfo` through result extensions as a `WeakRef`, enabling safe access without retaining strong references.

🐛 Bug Fixes

  • Ensure that merge functions are not called multiple times for the same incremental chunk, preventing redundant processing.

🔧 Affected Symbols

Cache.writeQueryCache.writeCache.updateExtensionsWithStreamInfoDefer20220824Handler