import type { GraphQLSchema } from 'graphql'; import type { PromiseOrValue } from '@envelop/core'; import type { createFetch } from '@whatwg-node/fetch'; import type { ServerAdapterInitialContext } from '@whatwg-node/server'; export type GraphQLSchemaWithContext = GraphQLSchema & { _context?: TContext; }; export interface GraphQLParams, TExtensions = Record> { operationName?: string; query?: string; variables?: TVariables; extensions?: TExtensions; } export interface YogaInitialContext extends ServerAdapterInitialContext { /** * GraphQL Parameters */ params: GraphQLParams; /** * An object describing the HTTP request. */ request: Request; } export type CORSOptions = { origin?: string[] | string; methods?: string[]; allowedHeaders?: string[]; exposedHeaders?: string[]; credentials?: boolean; maxAge?: number; } | false; declare module 'graphql' { interface GraphQLHTTPErrorExtensions { spec?: boolean; status?: number; headers?: Record; } interface GraphQLErrorExtensions { http?: GraphQLHTTPErrorExtensions; } } export type FetchAPI = ReturnType; export interface FetchEvent extends Event { request: Request; respondWith(response: PromiseOrValue): void; } export type YogaMaskedErrorOpts = { maskError: MaskError; errorMessage: string; isDev?: boolean; }; export type MaskError = (error: unknown, message: string, isDev?: boolean) => Error; export type MaybeArray = T | T[]; export interface GraphQLHTTPExtensions { spec?: boolean; status?: number; headers?: Record; }