@apollo/client@4.1.0-alpha.3
π¦ apollo-client
β¨ 4 featuresπ 4 fixesπ§ 7 symbols
Summary
This release adds null and array support to fragment watching APIs, introduces a `getCurrentResult` helper, deduplicates duplicate watches for better performance, and includes several bug fixes and incremental delivery updates.
Migration Steps
- If your code relied on `DeepPartial<Array<TData>>` including `undefined` elements, update type expectations to the new `Array<DeepPartial<TData>>` shape.
- When using `client.watchFragment` or `cache.watchFragment`, handle the case where `from` may be `null` and the result `data` will be `null`.
- If you pass an array to `from` in `useFragment` or `client.watchFragment`, adjust your component logic to expect `data` as an array matching the input order.
β¨ New Features
- Add support for `from: null` in `client.watchFragment` and `cache.watchFragment`, returning a result with `data: null`, `dataState: \"complete\"`, and `complete: true`.
- Add support for arrays with `useFragment`, `useSuspenseFragment`, and `client.watchFragment`, allowing multiple entities to be watched and returning `data` as an array aligned with the `from` array.
- Add a `getCurrentResult` function to the observable returned by `client.watchFragment` and `cache.watchFragment` to retrieve the current fragment value.
- Deduplicate watches created by `useFragment`, `client.watchFragment`, and `cache.watchFragment` that share the same fragment, variables, and identifier, improving performance.
π Bug Fixes
- Ignore topβlevel `data` values on subsequent chunks in incremental responses.
- Fix the `Defer20220824Handler.SubsequentResult` type to match `FormattedSubsequentIncrementalExecutionResult` in `graphql@17.0.0-alpha.2`.
- Update the `accept` header used with `GraphQL17Alpha9Handler` to `multipart/mixed;incrementalSpec=v0.2` to request the newest incremental delivery format.
- `DeepPartial<Array<TData>>` now returns `Array<DeepPartial<TData>>` instead of `Array<DeepPartial<TData | undefined>>`.
π§ Affected Symbols
client.watchFragmentcache.watchFragmentuseFragmentuseSuspenseFragmentDeepPartialDefer20220824Handler.SubsequentResultGraphQL17Alpha9Handler