v3.13.0-rc.0
📦 apollo-client
✨ 3 features🐛 5 fixes⚡ 3 deprecations🔧 7 symbols
Summary
This release introduces the useSuspenseFragment hook, improves type safety for updateQuery, adds multipart query deduplication, deprecates several callbacks and options, and includes several bug fixes and type corrections.
Migration Steps
- Replace useFragment with useSuspenseFragment where you want React Suspense to manage loading state.
- Update observableQuery.updateQuery callbacks to use the second argument's previousData and complete fields instead of the first argument.
- Remove usage of onCompleted and onError callbacks from useQuery and useLazyQuery; handle results via the returned data/error fields.
- Stop using the ignoreResults option in useMutation; use useApolloClient and client.mutate directly if you need to avoid component re‑renders.
- Adjust error handling for useMutation onCompleted callbacks to expect promise rejection instead of onError being called.
✨ New Features
- Added new useSuspenseFragment hook that suspends until fragment data is complete, serving as a drop‑in replacement for useFragment when using React Suspense.
- Provided a more type‑safe API for observableQuery.updateQuery by introducing a second argument with previousData and complete properties.
- Query deduplication now continues through all multipart response chunks (e.g., when using @defer) until the final chunk is received.
🐛 Bug Fixes
- Errors thrown in the onCompleted callback of useMutation no longer trigger onError.
- Mutation promises are now rejected if errors are thrown in the onCompleted callback of useMutation.
- Fixed updateQuery return type to allow undefined, enabling bail‑out of updates without type errors.
- Corrected the type of the variables property passed to the subscribeToMore updateQuery callback to reflect query variables.
- Ensured that errors thrown in the onCompleted callback from useMutation don't call onError.
🔧 Affected Symbols
useSuspenseFragmentuseFragmentuseMutationuseQueryuseLazyQueryobservableQuery.updateQuerysubscribeToMore⚡ Deprecations
- onCompleted and onError callbacks of useQuery and useLazyQuery are deprecated; use the new result handling patterns instead.
- The first argument (unsafePreviousData) of observableQuery.updateQuery is deprecated and will be removed in a future version; use the second argument's previousData property instead.
- The ignoreResults option in useMutation is deprecated; switch to using useApolloClient and client.mutate directly if you need to avoid component re‑renders.