UNPKG

@stewartmcgown/apollo-response-cache

Version:

Caching and invalidation mechanisms (plugins, directives) of Apollo GraphQL

29 lines (28 loc) 710 B
import { RedisCache } from 'apollo-server-cache-redis'; export declare type Node = { type: string; id: string; }; /** * Generate cache key of Node and FQC hashes array mapping * * e.g. ['Article', 18] -> 'node-fqcs:Article:18' */ export declare const toNodeFQCKey: (node: Node) => string; /** * Record Node:FQC mapping * */ export declare const recordNodeFQCMapping: ({ nodeFQCKeys, fqcKey, ttl, redis, }: { nodeFQCKeys: string[]; fqcKey: string; ttl: number; redis: RedisCache; }) => void; /** * Invalidate full query caches by the given related node keys */ export declare const invalidateFQC: ({ node, redis, }: { node: Node; redis: RedisCache; }) => Promise<void>;