import type { ExecutionResult } from 'graphql'; import type { Maybe, PromiseOrValue } from '@envelop/core'; export type CacheEntityRecord = { typename: string; id?: number | string; }; /** * Interface for implementing a cache that will be used for `useResponseCache`. */ export type Cache = { /** set a cache response */ set( /** id/hash of the operation */ id: string, /** the result that should be cached */ data: ExecutionResult, /** array of entity records that were collected during execution */ entities: Iterable, /** how long the operation should be cached */ ttl: number): PromiseOrValue; /** get a cached response */ get(id: string): PromiseOrValue>; /** invalidate operations via typename or id */ invalidate(entities: Iterable): PromiseOrValue; };