UNPKG

1.09 kBTypeScriptView Raw
1import { GraphQLParams, Plugin, PromiseOrValue } from 'graphql-yoga';
2export declare type ExtractPersistedOperationId = (params: GraphQLParams) => null | string;
3export declare const defaultExtractPersistedOperationId: ExtractPersistedOperationId;
4declare type AllowArbitraryOperationsHandler = (request: Request) => PromiseOrValue<boolean>;
5export interface UsePersistedOperationsOptions {
6 /**
7 * A function that fetches the persisted operation
8 */
9 getPersistedOperation(key: string): PromiseOrValue<string | null>;
10 /**
11 * Whether to allow execution of arbitrary GraphQL operations aside from persisted operations.
12 */
13 allowArbitraryOperations?: boolean | AllowArbitraryOperationsHandler;
14 /**
15 * The path to the persisted operation id
16 */
17 extractPersistedOperationId?: ExtractPersistedOperationId;
18}
19export declare function usePersistedOperations<TPluginContext extends Record<string, any>>({ getPersistedOperation, allowArbitraryOperations, extractPersistedOperationId, }: UsePersistedOperationsOptions): Plugin<TPluginContext>;
20export {};