v4.0.0-alpha.5
Breaking Changes📦 apollo-client
⚠ 5 breaking✨ 5 features🐛 2 fixes🔧 12 symbols
Summary
The update replaces `FetchResult` with new `SubscribeResult` and `MutateResult` types, removes deprecated subscription callbacks, unifies error handling, and includes several bug fixes and SSR improvements.
⚠️ Breaking Changes
- Removed `variables` from the result returned by `useSubscription`; code accessing `result.variables` will break. Update to use the new result shape.
- Subscriptions now emit a `SubscribeResult` instead of a `FetchResult`; the `errors` field is replaced by `error`. Update type imports and error handling.
- `client.mutate` and `useMutation` now return a `MutateResult` instead of a `FetchResult`; the `errors` property is replaced by `error`. Adjust return type handling.
- Deprecated callbacks `onSubscriptionData` and `onSubscriptionComplete` have been removed from `useSubscription`. Replace them with `onData` and `onComplete`.
- SSR-specific `RenderPromises` have been removed from `useQuery`. Remove any imports or usage of `RenderPromises`.
Migration Steps
- Import and use `SubscribeResult` (or update existing imports) instead of `FetchResult` for subscription hooks.
- Replace any access to `result.errors` with `result.error` for both subscriptions and mutations.
- Update code that relied on `variables` in the subscription result to no longer expect that field.
- Replace `onSubscriptionData` with `onData` and `onSubscriptionComplete` with `onComplete` in `useSubscription` calls.
- Remove any usage of `RenderPromises` from `useQuery` implementations.
- If you used `client.mutate` result properties beyond the standard fields, adjust to the stripped result shape.
✨ New Features
- Introduced `SubscribeResult` type for subscription results.
- Introduced `MutateResult` type for mutation results.
- Unified error handling for mutations and subscriptions under `errorPolicy`.
- Split out SSR-specific code from `useQuery` and removed `RenderPromises`.
- Adjusted priority logic for `ssr: false` in `useQuery` to align with `skip` and `fetchPolicy:"standby"`.
🐛 Bug Fixes
- Fixed `onError` handling in `useMutation` so that the promise rejects instead of resolves when `errorPolicy` is `none`.
- Stripped out unexpected additional response properties (e.g., `@defer` payload fields) from `client.mutate` results to match TypeScript types.
🔧 Affected Symbols
useSubscriptionSubscribeResultFetchResultclient.mutateMutateResultuseMutationonSubscriptionDataonSubscriptionCompleteonDataonCompleteuseQueryRenderPromises