UNPKG

@graphql-yoga/plugin-persisted-operations

Version:

Persisted Operations plugin for GraphQL Yoga.

21 lines (20 loc) 1.07 kB
import { GraphQLParams, Plugin, PromiseOrValue } from 'graphql-yoga'; export type ExtractPersistedOperationId = (params: GraphQLParams) => null | string; export declare const defaultExtractPersistedOperationId: ExtractPersistedOperationId; type AllowArbitraryOperationsHandler = (request: Request) => PromiseOrValue<boolean>; export interface UsePersistedOperationsOptions { /** * A function that fetches the persisted operation */ getPersistedOperation(key: string): PromiseOrValue<string | null>; /** * Whether to allow execution of arbitrary GraphQL operations aside from persisted operations. */ allowArbitraryOperations?: boolean | AllowArbitraryOperationsHandler; /** * The path to the persisted operation id */ extractPersistedOperationId?: ExtractPersistedOperationId; } export declare function usePersistedOperations<TPluginContext extends Record<string, any>>({ getPersistedOperation, allowArbitraryOperations, extractPersistedOperationId, }: UsePersistedOperationsOptions): Plugin<TPluginContext>; export {};