@@ -7,6 +7,19 @@ import type { SourceLocation } from '../language/location';
7
7
import { getLocation } from '../language/location' ;
8
8
import { printLocation , printSourceLocation } from '../language/printLocation' ;
9
9
10
+ /**
11
+ * Custom extensions
12
+ *
13
+ * @remarks
14
+ * Use a unique identifier name for your extension, for example the name of
15
+ * your library or project. Do not use a shortened identifier as this increases
16
+ * the risk of conflicts. We recommend you add at most one extension field,
17
+ * an object which can contain all the values you need.
18
+ */
19
+ export interface GraphQLErrorExtensions {
20
+ [ attributeName : string ] : unknown ;
21
+ }
22
+
10
23
/**
11
24
* A GraphQLError describes an Error found during the parse, validate, or
12
25
* execute phases of performing a GraphQL operation. In addition to a message
@@ -61,7 +74,7 @@ export class GraphQLError extends Error {
61
74
/**
62
75
* Extension fields to add to the formatted error.
63
76
*/
64
- readonly extensions : { [ key : string ] : unknown } ;
77
+ readonly extensions : GraphQLErrorExtensions ;
65
78
66
79
constructor (
67
80
message : string ,
@@ -70,7 +83,7 @@ export class GraphQLError extends Error {
70
83
positions ?: Maybe < ReadonlyArray < number > > ,
71
84
path ?: Maybe < ReadonlyArray < string | number > > ,
72
85
originalError ?: Maybe < Error & { readonly extensions ?: unknown } > ,
73
- extensions ?: Maybe < { [ key : string ] : unknown } > ,
86
+ extensions ?: Maybe < GraphQLErrorExtensions > ,
74
87
) {
75
88
super ( message ) ;
76
89
0 commit comments