releases.shpreview

@apollo/client@4.3.0-alpha.0

Minor Changes

  • #13250 bad7035 Thanks @jerelmiller! - Add the ability to define the cache type for the client. client.cache currently returns ApolloCache as the cache type regardless of what cache you've provided to ApolloClient.

    Declare the cache type using the cache property in the TypeOverrides interface 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 cache is 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 cache option for the ApolloClient constructor.

Fetched June 9, 2026