Sourced from @apollo/client's releases.
@apollo/client@4.2.0Minor Changes
#13132
f3ce805Thanks@phryneas! - Introduce "classic" and "modern" method and hook signatures.Apollo Client 4.2 introduces two signature styles for methods and hooks. All signatures previously present are now "classic" signatures, and a new set of "modern" signatures are added alongside them.
Classic signatures are the default and are identical to the signatures before Apollo Client 4.2, preserving backward compatibility. Classic signatures still work with manually specified TypeScript generics (e.g.,
useSuspenseQuery<MyData>(...)). However, manually specifying generics has been discouraged for a long time—instead, we recommend usingTypedDocumentNodeto automatically infer types, which provides more accurate results without any manual annotations.Modern signatures automatically incorporate your declared
defaultOptionsinto return types, providing more accurate types. Modern signatures infer types from the document node and do not support manually passing generic type arguments; TypeScript will produce a type error if you attempt to do so.Methods and hooks automatically switch to modern signatures the moment any non-optional property is declared in
DeclareDefaultOptions. The switch happens across all methods and hooks globally:// apollo.d.ts import "@apollo/client"; declare module "@apollo/client" { namespace ApolloClient { namespace DeclareDefaultOptions { interface WatchQuery { errorPolicy: "all"; // non-optional → modern signatures activated automatically } } } }Users can also manually switch to modern signatures without declaring any
defaultOptions, for example when wanting accurate type inference without relying on globaldefaultOptions:// apollo.d.ts import "@apollo/client"; declare module "@apollo/client" { export interface TypeOverrides { signatureStyle: "modern"; } }Users can do a global
DeclareDefaultOptionstype augmentation and then manually switch back to "classic" for migration purposes:// apollo.d.ts import "@apollo/client"; declare module "@apollo/client" { export interface TypeOverrides { signatureStyle: "classic"; } }
... (truncated)
Sourced from @apollo/client's changelog.
4.2.0
Minor Changes
#13132
f3ce805Thanks@phryneas! - Introduce "classic" and "modern" method and hook signatures.Apollo Client 4.2 introduces two signature styles for methods and hooks. All signatures previously present are now "classic" signatures, and a new set of "modern" signatures are added alongside them.
Classic signatures are the default and are identical to the signatures before Apollo Client 4.2, preserving backward compatibility. Classic signatures still work with manually specified TypeScript generics (e.g.,
useSuspenseQuery<MyData>(...)). However, manually specifying generics has been discouraged for a long time—instead, we recommend usingTypedDocumentNodeto automatically infer types, which provides more accurate results without any manual annotations.Modern signatures automatically incorporate your declared
defaultOptionsinto return types, providing more accurate types. Modern signatures infer types from the document node and do not support manually passing generic type arguments; TypeScript will produce a type error if you attempt to do so.Methods and hooks automatically switch to modern signatures the moment any non-optional property is declared in
DeclareDefaultOptions. The switch happens across all methods and hooks globally:// apollo.d.ts import "@apollo/client"; declare module "@apollo/client" { namespace ApolloClient { namespace DeclareDefaultOptions { interface WatchQuery { errorPolicy: "all"; // non-optional → modern signatures activated automatically } } } }Users can also manually switch to modern signatures without declaring any
defaultOptions, for example when wanting accurate type inference without relying on globaldefaultOptions:// apollo.d.ts import "@apollo/client"; declare module "@apollo/client" { export interface TypeOverrides { signatureStyle: "modern"; } }Users can do a global
DeclareDefaultOptionstype augmentation and then manually switch back to "classic" for migration purposes:// apollo.d.ts import "@apollo/client"; declare module "@apollo/client" { export interface TypeOverrides { signatureStyle: "classic"; } }
... (truncated)
e010bdd
Version Packages (#13241)9c4c01a
Release 4.2 (#13129)222838e
Exit prerelease mode7d3a533
Merge branch 'main' into release-4.2f20d591
chore(deps): update actions/create-github-app-token digest to d72941d
(#13239)d4a28b6
chore(deps): pin dependencies (#13237)c1f39cf
ci: pin Actions@SHA and disable cache on workflows with elevated OIDC
permiss...511048b
Event-based refetching docs (#13228)d1f68f1
Version Packages (rc) (#13234)f1b541f
Prepare for rc release (#13232)