UNPKG

@envelop/graphql-jit

Version:

This plugins replaces the original `execute` of GraphQL with [`graphql-jit`](https://github.com/zalando-incubator/graphql-jit).

27 lines (26 loc) 944 B
import { Plugin } from '@envelop/core'; import { ExecutionArgs, ExecutionResult } from 'graphql'; import { CompilerOptions, CompiledQuery } from 'graphql-jit'; declare type JITCacheEntry = { query: CompiledQuery['query']; subscribe?: CompiledQuery['subscribe']; }; export interface JITCache { get(key: string): JITCacheEntry | undefined; set(key: string, value: JITCacheEntry): void; } export declare const useGraphQlJit: (compilerOptions?: Partial<CompilerOptions>, pluginOptions?: { /** * A helper function that helps to conditionally enable JIT based on incoming request */ enableIf?: ((executionArgs: ExecutionArgs) => boolean | Promise<boolean>) | undefined; /** * Callback triggered in case of GraphQL Jit compilation error. */ onError?: ((r: ExecutionResult) => void) | undefined; /** * Custom cache instance */ cache?: JITCache | undefined; }) => Plugin; export {};