Change8

@apollo/client@4.1.0-alpha.9

📦 apollo-client
2 features🐛 1 fixes🔧 7 symbols

Summary

This release adds new cache behavior for undefined array items, introduces an \`extensions\` option to cache write methods, and improves fragment hooks with memoized observable mapping.

Migration Steps

  1. If your custom \`read\` functions for array fields relied on undefined items being filtered out, update them to handle undefined values explicitly.
  2. Update any code that expects \`extensions\` to be unavailable in cache merge functions; now they are provided via the new \`extensions\` option.

✨ New Features

  • InMemoryCache no longer filters out explicitly returned undefined items from read functions for array fields, allowing read functions on array fields to return partial data and trigger a fetch for the full list.
  • Added an \`extensions\` option to \`cache.write\`, \`cache.writeQuery\`, and \`client.writeQuery\`, making extensions available in cache \`merge\` functions and exposing extensions returned in GraphQL operations to merge.

🐛 Bug Fixes

  • Implemented memoized observable mapping for \`watchFragment\`, \`useFragment\`, and \`useSuspenseFragment\` to improve performance and consistency.

🔧 Affected Symbols

InMemoryCachecache.writecache.writeQueryclient.writeQuerywatchFragmentuseFragmentuseSuspenseFragment