UNPKG

graphql-yoga

Version:
39 lines (38 loc) • 2.17 kB
import { GraphQLError } from 'graphql'; import { HTTPError, InvalidContentLengthError, RequestBodyTooLargeError } from '@whatwg-node/server'; import type { ResultProcessorInput } from './plugins/types.cjs'; import type { FetchAPI, GraphQLHTTPExtensions, YogaConfigContext, YogaInitialContext, YogaMaskedErrorOpts } from './types.cjs'; declare module 'graphql' { interface GraphQLError { /** * Optional schema coordinate (e.g. "MyType.myField") associated with this error. * Experimental; populated when useErrorCoordinate / schemaCoordinateInErrors is enabled. */ readonly coordinate?: string; } interface GraphQLErrorExtensions { http?: GraphQLHTTPExtensions; unexpected?: boolean; } } /** * Attach experimental schema `coordinate` to a GraphQLError. * graphql-js GraphQLErrorOptions does not know about coordinate yet, so this * uses defineProperty (same approach as `@graphql-tools/utils` locatedError). * * Prefer reading with `getSchemaCoordinate` from `@graphql-tools/utils`. */ export declare function withSchemaCoordinate(error: GraphQLError, coordinate: string | undefined): GraphQLError; export declare function isGraphQLError(val: unknown): val is GraphQLError; export declare function isOriginalGraphQLError(val: unknown): val is GraphQLError & { originalError: GraphQLError; }; export declare function isAbortError(error: unknown): error is DOMException; export declare function isRequestBodyLimitError(error: unknown): error is RequestBodyTooLargeError | InvalidContentLengthError; export declare function responseFromBodyLimitError(error: HTTPError, fetchAPI: Pick<FetchAPI, 'Response'>): Response; export declare function handleError(error: unknown, maskedErrorsOpts: YogaMaskedErrorOpts | null, context: Partial<YogaInitialContext> & YogaConfigContext): GraphQLError[]; export declare function getResponseInitByRespectingErrors(result: ResultProcessorInput, headers?: Record<string, string>, isApplicationJson?: boolean): { status: number; headers: Record<string, string>; }; export declare function areGraphQLErrors(obj: unknown): obj is readonly GraphQLError[];