Change8

@apollo/client@4.2.10

📦 apollo-clientView on GitHub →
🐛 4 fixes🔧 5 symbols

Summary

This patch release addresses several type-related bugs in Apollo Client, improving the accuracy of return types for mutations, queries with constant variable types, and options passed to various API functions. It also refines the return types for `refetch`, `fetchMore`, and `useLazyQuery` based on the provided `errorPolicy`.

🐛 Bug Fixes

  • Fix accidental widening of the `client.mutate` return type when `optimisticResponse` was present.
  • Fix result types widened when a query's variables had constant types (e.g. `TypedDocumentNode<Data, { type: "main" }>`). This caused options such as `returnPartialData` or `errorPolicy` to be reported as their widened types (e.g. `boolean`, `ErrorPolicy`) instead of the value that was passed which returned the wrong `data` and `dataState` types.
  • Fix issue where unknown options were permitted by TypeScript when passed alongside a valid option to APIs with modern signatures.
  • Update the return type of `refetch`, `fetchMore` and `useLazyQuery`'s `execute` function on the provided `errorPolicy`. Previously these APIs all used the default type which typed `data` as `TData | undefined` and `error` as `ErrorLike | undefined`.

Affected Symbols