@graphql-yoga/plugin-response-cache
Version:
For the documentation check `http://graphql-yoga.com/docs/response-cache`
21 lines (20 loc) • 1.05 kB
TypeScript
import { createInMemoryCache, UseResponseCacheParameter as UseEnvelopResponseCacheParameter, Cache as EnvelopCache, ResponseCacheExtensions as EnvelopResponseCacheExtensions } from '@envelop/response-cache';
import { ExecutionResult } from 'graphql';
import { Maybe, Plugin, PromiseOrValue } from 'graphql-yoga';
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 };