UNPKG

@graphql-yoga/plugin-response-cache

Version:

For the documentation check `http://graphql-yoga.com/docs/response-cache`

21 lines (20 loc) 1.05 kB
import { ExecutionResult } from 'graphql'; import { Maybe, Plugin, PromiseOrValue } from 'graphql-yoga'; import { createInMemoryCache, Cache as EnvelopCache, ResponseCacheExtensions as EnvelopResponseCacheExtensions, UseResponseCacheParameter as UseEnvelopResponseCacheParameter } from '@envelop/response-cache'; export type UseResponseCacheParameter = Omit<UseEnvelopResponseCacheParameter, 'getDocumentString' | 'session' | 'cache' | 'enabled'> & { cache?: Cache; session: (request: Request) => PromiseOrValue<Maybe<string>>; enabled?: (request: Request) => boolean; }; export interface ResponseCachePluginExtensions { http?: { headers?: Record<string, string>; }; responseCache: EnvelopResponseCacheExtensions; [key: string]: unknown; } interface Cache extends EnvelopCache { get(key: string): Promise<ExecutionResult<Record<string, unknown>, ResponseCachePluginExtensions> | undefined>; } export declare function useResponseCache(options: UseResponseCacheParameter): Plugin; export { createInMemoryCache };