@graphql-yoga/plugin-apq
Version:
APQ plugin for GraphQL Yoga.
27 lines (26 loc) • 835 B
TypeScript
import { Plugin, PromiseOrValue } from 'graphql-yoga';
export declare function hashSHA256(str: string, api?: {
crypto: Crypto;
TextEncoder: typeof globalThis['TextEncoder'];
}): Promise<string>;
export interface APQStoreOptions {
max?: number;
ttl?: number;
}
export declare function createInMemoryAPQStore(options?: APQStoreOptions): APQStore;
export interface APQOptions {
store?: APQStore;
hash?: (str: string, api: {
crypto: Crypto;
TextEncoder: typeof TextEncoder;
}) => PromiseOrValue<string>;
}
export interface APQStore {
get(key: string): PromiseOrValue<string | null | undefined>;
set(key: string, query: string): PromiseOrValue<any>;
}
export interface APQExtension {
version: 1;
sha256Hash: string;
}
export declare function useAPQ(options?: APQOptions): Plugin;