Skip to content

@apollo/client@4.3.0-alpha.0

Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 09 Jun 15:37
· 0 commits to main since this release
9cd2f1d

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.