Apollo Cache Router is a utility that routes GraphQL operations to different caches based on directives or query names. Version 1.1.6, last updated in 2019, it extends Apollo Client's cache layer by allowing multiple InMemoryCache instances and custom routing logic. It supports TypeScript, uses ESM imports, and is useful for separating client-only and network GraphQL data. Differentiates from standard Apollo Cache by enabling conditional cache selection via a routing function and cache overrides for lifecycle methods. Requires apollo-cache and graphql as peer dependencies.
npm install apollo-cache-routerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a routed cache that sends @client queries to localCache and others to netCache, with custom reset logic.
Consider forking or using alternative cache management.
Provide array of caches as first argument to route().
Use as any or cast types if needed.
Implement custom override object with required methods only.
Run 'npm install apollo-cache-router'
Use 'import ApolloCacheRouter from 'apollo-cache-router''
Call ApolloCacheRouter.route([cache1, cache2], document => ...)