Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change type of error extensions from anonymous Record to named interfaces #3327

Merged
merged 1 commit into from Oct 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/error/GraphQLError.d.ts
Expand Up @@ -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
Expand All @@ -18,7 +31,7 @@ export class GraphQLError extends Error {
positions?: Maybe<ReadonlyArray<number>>,
path?: Maybe<ReadonlyArray<string | number>>,
originalError?: Maybe<Error>,
extensions?: Maybe<{ [key: string]: any }>,
extensions?: Maybe<{ [key: string]: GraphQLErrorExtensions }>,
);

/**
Expand Down
6 changes: 5 additions & 1 deletion 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';
1 change: 1 addition & 0 deletions src/index.d.ts
Expand Up @@ -364,6 +364,7 @@ export {
printError,
formatError,
GraphQLFormattedError,
GraphQLErrorExtensions,
} from './error/index';

// Utilities for operating on GraphQL type schema and parsed sources.
Expand Down