import type { DocumentNode, GraphQLErrorOptions } from 'graphql'; import type { GraphQLParams, OnParamsEventPayload, Plugin, PromiseOrValue } from 'graphql-yoga'; export type ExtractPersistedOperationId> = (params: GraphQLParams, request: Request, context: TPluginContext) => null | string; export declare const defaultExtractPersistedOperationId: ExtractPersistedOperationId; type AllowArbitraryOperationsHandler = (request: Request) => PromiseOrValue; export type UsePersistedOperationsOptions> = { /** * A function that fetches the persisted operation */ getPersistedOperation(key: string, request: Request, context: TPluginContext): PromiseOrValue; /** * Whether to allow execution of arbitrary GraphQL operations aside from persisted operations. */ allowArbitraryOperations?: boolean | AllowArbitraryOperationsHandler; /** * The path to the persisted operation id */ extractPersistedOperationId?: ExtractPersistedOperationId; /** * Whether to skip validation of the persisted operation */ skipDocumentValidation?: boolean; /** * Custom errors to be thrown */ customErrors?: CustomPersistedQueryErrors; }; export type CustomErrorFactory = string | (GraphQLErrorOptions & { message: string; }) | ((payload: OnParamsEventPayload) => Error); export type CustomPersistedQueryErrors = { /** * Error to be thrown when the persisted operation is not found */ notFound?: CustomErrorFactory; /** * Error to be thrown when rejecting non-persisted operations */ persistedQueryOnly?: CustomErrorFactory; /** * Error to be thrown when the extraction of the persisted operation id failed */ keyNotFound?: CustomErrorFactory; }; export declare function usePersistedOperations>({ allowArbitraryOperations, extractPersistedOperationId, getPersistedOperation, skipDocumentValidation, customErrors }: UsePersistedOperationsOptions): Plugin; export {};