@apollo/[email protected]
@apollo/[email protected]
@apollo/client
Release Notes
Minor Changes
#13250
bad7035Thanks @jerelmiller! - Add the ability to define the cache type for the client.client.cachecurrently returnsApolloCacheas the cache type regardless of what cache you've provided toApolloClient.Declare the cache type using the
cacheproperty in theTypeOverridesinterface to set the cache implementation used for the client.// apollo.d.ts import type { InMemoryCache } from "@apollo/client"; declare module "@apollo/client" { export interface TypeOverrides { cache: InMemoryCache; } }Now anywhere
cacheis accessible, the type is the declared cache type:client.cache; // ^? InMemoryCache client.mutate({ update: (cache) => { // ^? InMemoryCache }, });[!NOTE] Setting a cache type enforces that cache type in the
cacheoption for theApolloClientconstructor.