Registry / testing / apollo-cache-logger

apollo-cache-logger

JSON →
library1.1.1jsnpmunverified

Apollo Cache Logger is a debugging utility for Apollo Client that wraps any Apollo cache implementation (e.g., InMemoryCache) and logs all cache read and diff operations. Version 1.1.1 is the latest stable release; the package has seen no updates since 2018 (low release cadence). It intercepts cache calls and prints the query along with the cache result, aiding in GraphQL cache debugging. Key differentiator: lightweight, zero-config logging that works with any Apollo cache without modifying existing code.

npm install apollo-cache-logger
INSTALL
IMPORT
SIG · APOLLO-CACHE-LOGGE
A
apollo-cache-logger
testingjavascriptv1.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import LogCache from 'apollo-cache-logger'
const { LogCache } = require('apollo-cache-logger')
The package exports a default class, not a named export. Use default import in ESM.
require (CJS)
const LogCache = require('apollo-cache-logger').default
const LogCache = require('apollo-cache-logger')
In CommonJS, access the default export via .default, or use ESM import.
TypeScript type (none)
const cache = new LogCache(new InMemoryCache(), { logger: console.log })
import { LogCache } from 'apollo-cache-logger' (named import does not exist)
TypeScript types are shipped but the export is default; use default import.

Shows how to import LogCache and wrap an InMemoryCache with a custom logger function.

import { InMemoryCache } from 'apollo-cache-inmemory'; import LogCache from 'apollo-cache-logger'; const cache = new LogCache(new InMemoryCache(), { logger: (msg: string) => console.log(msg) }); // Use cache as usual with Apollo Client // const client = new ApolloClient({ cache }); // Example cache operations will now be logged cache.readQuery({ query: gql`{ data }` });
Debug
Known issues
deprecatedPackage is unmaintained since 2018. No updates for modern Apollo Client (v3+) which uses @apollo/client cache instead of apollo-cache.
fix
Switch to Apollo Client DevTools or use a custom Apollo link for logging in newer versions.
affects: >=1.1.0
breakingPackaged as CJS with exported default via module.exports = { default: LogCache }. CommonJS require returns an object with default property, not the class directly.
fix
Use ESM import or CJS require with .default.
affects: >=1.0.0
gotchaThe logger option is passed as second argument; if omitted, logs go to console.log.
fix
Omitting logger defaults to console.log, no error.
affects: >=1.0.0
gotchaRequires peer dependencies apollo-cache and graphql to be installed separately.
fix
Install with --save-dev, but ensure apollo-cache and graphql are in dependencies.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: LogCache is not a constructor
Using named import instead of default import in ESM or forgetting .default in CJS.
fix
import LogCache from 'apollo-cache-logger' (ESM) or const LogCache = require('apollo-cache-logger').default (CJS)
Cannot find module 'apollo-cache'
Missing peer dependency apollo-cache.
fix
npm install apollo-cache graphql
TypeError: cache.readQuery is not a function
LogCache expects a valid Apollo cache instance, not a plain object.
fix
new LogCache(new InMemoryCache(), ...)
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies
apollo-cacherequiredpeer dependency; provides the base cache interface to wrap
graphqlrequiredpeer dependency; required by Apollo cache for query parsing
Agent activity
33 hits · last 30 days
node
26
OpenAI (training)
1
Resources
apollo-cache-logger — npm install apollo-cache-logger · libregistry