@apollo/client@4.2.0-alpha.3
📦 apollo-clientView on GitHub →
✨ 4 features🔧 5 symbols
Summary
This release enhances type safety for mutations by propagating the `errorPolicy` setting from `defaultOptions` and individual calls into the return types of `client.mutate` and `useMutation`.
Migration Steps
- If using custom default options for mutations, ensure the structure aligns with the new type-safety enhancements, particularly regarding the `errorPolicy` declaration within `ApolloClient.DeclareDefaultOptions.Mutate`.
✨ New Features
- Extended `defaultOptions` type-safety work to `client.mutate` and `useMutation`.
- The `errorPolicy` option now flows through to mutation result types, narrowing `data` and `error` shapes based on the policy ("none", "all", or "ignore").
- Return types for `client.mutate` and `useMutation` now reflect the declared `defaultOptions.mutate.errorPolicy` or the explicit `errorPolicy` provided in the call.
- The `useMutation.Result.error` type is narrowed to `undefined` when `errorPolicy` is set to "ignore".