diff --git a/src/error/GraphQLError.d.ts b/src/error/GraphQLError.d.ts index 99001fd26f..5357db7d0d 100644 --- a/src/error/GraphQLError.d.ts +++ b/src/error/GraphQLError.d.ts @@ -4,6 +4,19 @@ import { ASTNode } from '../language/ast'; import { Source } from '../language/source'; import { SourceLocation } from '../language/location'; +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ +export interface GraphQLErrorExtensions { + [attributeName: string]: any; +} + /** * A GraphQLError describes an Error found during the parse, validate, or * execute phases of performing a GraphQL operation. In addition to a message @@ -18,7 +31,7 @@ export class GraphQLError extends Error { positions?: Maybe>, path?: Maybe>, originalError?: Maybe, - extensions?: Maybe<{ [key: string]: any }>, + extensions?: Maybe<{ [key: string]: GraphQLErrorExtensions }>, ); /** diff --git a/src/error/index.d.ts b/src/error/index.d.ts index 9373b7167d..38f7b7e3b6 100644 --- a/src/error/index.d.ts +++ b/src/error/index.d.ts @@ -1,4 +1,8 @@ -export { GraphQLError, printError } from './GraphQLError'; +export { + GraphQLError, + GraphQLErrorExtensions, + printError, +} from './GraphQLError'; export { syntaxError } from './syntaxError'; export { locatedError } from './locatedError'; export { formatError, GraphQLFormattedError } from './formatError'; diff --git a/src/index.d.ts b/src/index.d.ts index 104436ddce..13a465b4e1 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -364,6 +364,7 @@ export { printError, formatError, GraphQLFormattedError, + GraphQLErrorExtensions, } from './error/index'; // Utilities for operating on GraphQL type schema and parsed sources.