{"id":45043,"library":"graphql-hooks-memcache","title":"graphql-hooks-memcache","description":"In-memory caching implementation for graphql-hooks, currently at version 3.2.0. The package provides a simple LRU-based cache with configurable size and TTL, designed for use with the graphql-hooks React GraphQL client. It supports server-side rendering by allowing rehydration of cache state via initialState. Key differentiators are its minimal API surface and direct integration with graphql-hooks. The library is actively maintained as part of the nearform/graphql-hooks ecosystem.","status":"active","version":"3.2.0","language":"javascript","source_language":"en","source_url":"git://github.com/nearform/graphql-hooks","tags":["javascript","graphql","hooks","react","graphql-hooks","cache","ssr","server-side rendering","typescript"],"install":[{"cmd":"npm install graphql-hooks-memcache","lang":"bash","label":"npm"},{"cmd":"yarn add graphql-hooks-memcache","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphql-hooks-memcache","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package exports a single default function. Named import will result in undefined.","wrong":"import { memCache } from 'graphql-hooks-memcache'","symbol":"default export","correct":"import memCache from 'graphql-hooks-memcache'"},{"note":"Types are exported from graphql-hooks, not from this package. Use graphql-hooks for Cache type.","wrong":"import type { MemCache } from 'graphql-hooks-memcache'","symbol":"type import (if TypeScript)","correct":"import type { Cache } from 'graphql-hooks'"},{"note":"Package supports both ESM and CommonJS.","wrong":null,"symbol":"CommonJS require","correct":"const memCache = require('graphql-hooks-memcache')"}],"quickstart":{"code":"import { GraphQLClient } from 'graphql-hooks'\nimport memCache from 'graphql-hooks-memcache'\n\nconst client = new GraphQLClient({\n  url: '/graphql',\n  cache: memCache({ size: 100, ttl: 60000 })\n})\n\n// After SSR, rehydrate cache:\n// const cache = memCache({ initialState: window.__GRAPHQL_CACHE__ })","lang":"typescript","description":"Shows how to create a GraphQL client with an in-memory cache using graphql-hooks-memcache, including optional size and ttl options."},"warnings":[{"fix":"Use default import: import memCache from 'graphql-hooks-memcache'","message":"Importing named export 'memCache' will yield undefined. Package uses default export only.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use cache.getInitialState() on server and hydrate on client with graphql-hooks' useHydrateCache hook.","message":"The `initialState` option in memCache() was removed in v3. Use `getInitialState()` and `useHydrateCache` hook instead.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Serialize keys to string: cache.set(JSON.stringify(key), value)","message":"Cache key must be a string. Passing objects or numbers may cause unexpected behavior.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use manual cache.delete(key) for specific queries or cache.clear() to reset all.","message":"Cache does not support partial invalidation based on query fields; it operates on full query keys.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'3.2.0':17 'activ':74 'allow':50 'api':62 'base':25 'cach':8,26,53,89 'client':42 'configur':28 'current':14 'design':32 'differenti':58 'direct':65 'ecosystem':81 'graphql':2,12,38,41,69,83,87 'graphql-hook':11,37,68,86 'graphql-hooks-memcach':1 'hook':3,13,39,70,84,88 'implement':9 'in-memori':5 'initialst':56 'integr':66 'javascript':82 'key':57 'librari':72 'lru':24 'lru-bas':23 'maintain':75 'memcach':4 'memori':7 'minim':61 'nearform/graphql-hooks':80 'packag':19 'part':77 'provid':20 'react':40,85 'rehydr':51 'render':48,94 'server':46,92 'server-sid':45,91 'side':47,93 'simpl':22 'size':29 'ssr':90 'state':54 'support':44 'surfac':63 'ttl':31 'typescript':95 'use':34 'version':16 'via':55","created_at":"2026-06-07T12:53:05.391290+00:00","updated_at":"2026-06-07T12:53:05.391290+00:00","problems":[{"fix":"Use default import: import memCache from 'graphql-hooks-memcache'","cause":"Attempting to call memCache as a named import: import { memCache } from 'graphql-hooks-memcache'","error":"TypeError: memCache is not a function"},{"fix":"Run npm install graphql-hooks-memcache. Ensure tsconfig.json includes node_modules types.","cause":"Missing package install or TypeScript not resolving type definitions.","error":"Cannot find module 'graphql-hooks-memcache' or its corresponding type declarations."},{"fix":"Check for undefined: const result = cache.get(key) ?? null","cause":"cache.get may return undefined for missing keys. TypeScript strict mode catches this.","error":"Type 'undefined' is not assignable to type 'string' in cache.get(key)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/nearform/graphql-hooks/blob/master/packages/graphql-hooks-memcache#readme","github":"git://github.com/nearform/graphql-hooks","docs":null,"changelog":null,"pypi":null,"npm":"graphql-hooks-memcache","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}