UNPKG

@graphql-yoga/plugin-response-cache

Version:

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

26 lines (25 loc) 1.5 kB
import { ExecutionResult } from 'graphql'; import { Maybe, Plugin, PromiseOrValue } from 'graphql-yoga'; import { BuildResponseCacheKeyFunction as EnvelopBuildResponseCacheKeyFunction, Cache as EnvelopCache, ResponseCacheExtensions as EnvelopResponseCacheExtensions, UseResponseCacheParameter as UseEnvelopResponseCacheParameter } from '@envelop/response-cache'; export type BuildResponseCacheKeyFunction = (params: Omit<Parameters<EnvelopBuildResponseCacheKeyFunction>[0], 'context'> & { request: Request; }) => ReturnType<EnvelopBuildResponseCacheKeyFunction>; export type UseResponseCacheParameter = Omit<UseEnvelopResponseCacheParameter, 'getDocumentString' | 'session' | 'cache' | 'enabled' | 'buildResponseCacheKey'> & { cache?: Cache; session: (request: Request) => PromiseOrValue<Maybe<string>>; enabled?: (request: Request) => boolean; buildResponseCacheKey?: BuildResponseCacheKeyFunction; }; 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 declare const createInMemoryCache: (params?: import("@envelop/response-cache").InMemoryCacheParameter | undefined) => Cache; export {};