From 9f4f26d2f0062a04ac0b0ab03b71123ba11ecfb1 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Mon, 13 Jan 2025 16:17:06 +0100 Subject: [PATCH] no cyclical deps --- src/error/GraphQLError.d.ts | 40 ++++++++++++++++++++++++++++++++--- src/error/formatError.d.ts | 42 +------------------------------------ 2 files changed, 38 insertions(+), 44 deletions(-) diff --git a/src/error/GraphQLError.d.ts b/src/error/GraphQLError.d.ts index 2accc9c17d..edf0b4d2a6 100644 --- a/src/error/GraphQLError.d.ts +++ b/src/error/GraphQLError.d.ts @@ -4,9 +4,6 @@ import { ASTNode } from '../language/ast'; import { Source } from '../language/source'; import { SourceLocation } from '../language/location'; -// eslint-disable-next-line import/no-cycle -import { GraphQLFormattedError } from './formatError'; - /** * Custom extensions * @@ -96,3 +93,40 @@ export class GraphQLError extends Error { * about the error's position in the source. */ export function printError(error: GraphQLError): string; + +/** + * Given a GraphQLError, format it according to the rules described by the + * Response Format, Errors section of the GraphQL Specification. + */ +export function formatError(error: GraphQLError): GraphQLFormattedError; + +/** + * @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors + */ +export interface GraphQLFormattedError< + TExtensions extends Record = Record +> { + /** + * A short, human-readable summary of the problem that **SHOULD NOT** change + * from occurrence to occurrence of the problem, except for purposes of + * localization. + */ + readonly message: string; + /** + * If an error can be associated to a particular point in the requested + * GraphQL document, it should contain a list of locations. + */ + readonly locations?: ReadonlyArray; + /** + * If an error can be associated to a particular field in the GraphQL result, + * it _must_ contain an entry with the key `path` that details the path of + * the response field which experienced the error. This allows clients to + * identify whether a null result is intentional or caused by a runtime error. + */ + readonly path?: ReadonlyArray; + /** + * Reserved for implementors to extend the protocol however they see fit, + * and hence there are no additional restrictions on its contents. + */ + readonly extensions?: TExtensions; +} diff --git a/src/error/formatError.d.ts b/src/error/formatError.d.ts index 5420e30cc0..869e16f2e0 100644 --- a/src/error/formatError.d.ts +++ b/src/error/formatError.d.ts @@ -1,41 +1 @@ -import { SourceLocation } from '../language/location'; - -// eslint-disable-next-line import/no-cycle -import { GraphQLError } from './GraphQLError'; - -/** - * Given a GraphQLError, format it according to the rules described by the - * Response Format, Errors section of the GraphQL Specification. - */ -export function formatError(error: GraphQLError): GraphQLFormattedError; - -/** - * @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors - */ -export interface GraphQLFormattedError< - TExtensions extends Record = Record -> { - /** - * A short, human-readable summary of the problem that **SHOULD NOT** change - * from occurrence to occurrence of the problem, except for purposes of - * localization. - */ - readonly message: string; - /** - * If an error can be associated to a particular point in the requested - * GraphQL document, it should contain a list of locations. - */ - readonly locations?: ReadonlyArray; - /** - * If an error can be associated to a particular field in the GraphQL result, - * it _must_ contain an entry with the key `path` that details the path of - * the response field which experienced the error. This allows clients to - * identify whether a null result is intentional or caused by a runtime error. - */ - readonly path?: ReadonlyArray; - /** - * Reserved for implementors to extend the protocol however they see fit, - * and hence there are no additional restrictions on its contents. - */ - readonly extensions?: TExtensions; -} +export { formatError, GraphQLFormattedError } from './GraphQLError';