diff --git a/src/error/GraphQLError.ts b/src/error/GraphQLError.ts index b88d27a56c..77a5e78779 100644 --- a/src/error/GraphQLError.ts +++ b/src/error/GraphQLError.ts @@ -20,6 +20,19 @@ export interface GraphQLErrorExtensions { [attributeName: string]: unknown; } +/** + * Custom formatted 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 GraphQLFormattedErrorExtensions { + [attributeName: string]: unknown; +} + export interface GraphQLErrorOptions { nodes?: ReadonlyArray | ASTNode | null; source?: Maybe; @@ -275,7 +288,7 @@ export interface GraphQLFormattedError { * Reserved for implementors to extend the protocol however they see fit, * and hence there are no additional restrictions on its contents. */ - readonly extensions?: { [key: string]: unknown }; + readonly extensions?: GraphQLFormattedErrorExtensions; } /** diff --git a/src/error/index.ts b/src/error/index.ts index dd92e48364..7e5d267f50 100644 --- a/src/error/index.ts +++ b/src/error/index.ts @@ -3,6 +3,7 @@ export type { GraphQLErrorOptions, GraphQLFormattedError, GraphQLErrorExtensions, + GraphQLFormattedErrorExtensions, } from './GraphQLError'; export { syntaxError } from './syntaxError'; diff --git a/src/index.ts b/src/index.ts index 877939d879..73c713a203 100644 --- a/src/index.ts +++ b/src/index.ts @@ -398,6 +398,7 @@ export type { GraphQLErrorOptions, GraphQLFormattedError, GraphQLErrorExtensions, + GraphQLFormattedErrorExtensions, } from './error/index'; // Utilities for operating on GraphQL type schema and parsed sources.