v3.13.0
Breaking Changes📦 apollo-clientView on GitHub →
⚠ 4 breaking✨ 1 features🐛 5 fixes⚡ 3 deprecations🔧 10 symbols
Summary
Apollo Client 3.13.0 adds the `useSuspenseFragment` hook, improves TypeScript typings, and fixes several bugs, while deprecating several callbacks and options.
⚠️ Breaking Changes
- The first argument of `observableQuery.updateQuery` is deprecated and will be removed in a future version; switch to using the `previousData` and `complete` properties from the second argument.
- The return type of `observableQuery.updateQuery` now includes `undefined`, so callers must handle a possible undefined return value.
- The `variables` argument type in the `subscribeToMore` callback has been corrected to the query variables type; update TypeScript annotations accordingly.
- The `ignoreResults` option in `useMutation` is deprecated and will be removed; replace it with manual mutation handling via `useApolloClient` and `client.mutate`.
Migration Steps
- Replace `useFragment` with `useSuspenseFragment` in components that rely on React Suspense.
- Update `observableQuery.updateQuery` callbacks to use the second argument's `previousData` and `complete` fields and stop using the first argument.
- Handle possible `undefined` return values from `observableQuery.updateQuery`.
- Adjust TypeScript types for the `variables` parameter in `subscribeToMore` callbacks to the query variables type.
- Remove the `ignoreResults` option from `useMutation` calls and, if needed, perform mutations directly via `useApolloClient` and `client.mutate`.
- Replace usage of `onCompleted` and `onError` callbacks in `useQuery`/`useLazyQuery` with alternative patterns such as effect hooks or error boundaries.
✨ New Features
- New hook `useSuspenseFragment` added as a drop‑in replacement for `useFragment` when using React Suspense.
🐛 Bug Fixes
- Errors thrown in the `onCompleted` callback of `useMutation` no longer trigger the `onError` callback.
- Mutation promise is rejected if errors are thrown in the `onCompleted` callback of `useMutation`.
- Return type of `observableQuery.updateQuery` fixed to allow `undefined` for early bail‑out.
- Query deduplication for multipart responses now continues until the final chunk is received.
- Type of the `variables` property passed to the `subscribeToMore` callback corrected to match query variables.
🔧 Affected Symbols
useSuspenseFragmentuseFragmentobservableQuery.updateQuerysubscribeToMoreuseMutationuseQueryuseLazyQueryignoreResultsonCompletedonError⚡ Deprecations
- `onCompleted` and `onError` callbacks of `useQuery` and `useLazyQuery` are deprecated.
- The first argument of `observableQuery.updateQuery` (previous data) is deprecated.
- `ignoreResults` option in `useMutation` is deprecated.