1 | import type { Maybe } from '../jsutils/Maybe';
|
2 | import type { ASTNode } from '../language/ast';
|
3 | import type { SourceLocation } from '../language/location';
|
4 | import type { Source } from '../language/source';
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | export interface GraphQLErrorExtensions {
|
15 | [attributeName: string]: unknown;
|
16 | }
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | export interface GraphQLFormattedErrorExtensions {
|
27 | [attributeName: string]: unknown;
|
28 | }
|
29 | export interface GraphQLErrorOptions {
|
30 | nodes?: ReadonlyArray<ASTNode> | ASTNode | null;
|
31 | source?: Maybe<Source>;
|
32 | positions?: Maybe<ReadonlyArray<number>>;
|
33 | path?: Maybe<ReadonlyArray<string | number>>;
|
34 | originalError?: Maybe<
|
35 | Error & {
|
36 | readonly extensions?: unknown;
|
37 | }
|
38 | >;
|
39 | extensions?: Maybe<GraphQLErrorExtensions>;
|
40 | }
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | export declare class GraphQLError extends Error {
|
48 | |
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | readonly locations: ReadonlyArray<SourceLocation> | undefined;
|
59 | |
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | readonly path: ReadonlyArray<string | number> | undefined;
|
66 | |
67 |
|
68 |
|
69 | readonly nodes: ReadonlyArray<ASTNode> | undefined;
|
70 | |
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 | readonly source: Source | undefined;
|
77 | |
78 |
|
79 |
|
80 |
|
81 | readonly positions: ReadonlyArray<number> | undefined;
|
82 | |
83 |
|
84 |
|
85 | readonly originalError: Error | undefined;
|
86 | |
87 |
|
88 |
|
89 | readonly extensions: GraphQLErrorExtensions;
|
90 | constructor(message: string, options?: GraphQLErrorOptions);
|
91 | /**
|
92 | * @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
|
93 | */
|
94 | constructor(
|
95 | message: string,
|
96 | nodes?: ReadonlyArray<ASTNode> | ASTNode | null,
|
97 | source?: Maybe<Source>,
|
98 | positions?: Maybe<ReadonlyArray<number>>,
|
99 | path?: Maybe<ReadonlyArray<string | number>>,
|
100 | originalError?: Maybe<
|
101 | Error & {
|
102 | readonly extensions?: unknown;
|
103 | }
|
104 | >,
|
105 | extensions?: Maybe<GraphQLErrorExtensions>,
|
106 | );
|
107 | get [Symbol.toStringTag](): string;
|
108 | toString(): string;
|
109 | toJSON(): GraphQLFormattedError;
|
110 | }
|
111 | /**
|
112 | * See: https://spec.graphql.org/draft/#sec-Errors
|
113 | */
|
114 | export interface GraphQLFormattedError {
|
115 | /**
|
116 | * A short, human-readable summary of the problem that **SHOULD NOT** change
|
117 | * from occurrence to occurrence of the problem, except for purposes of
|
118 | * localization.
|
119 | */
|
120 | readonly message: string;
|
121 | /**
|
122 | * If an error can be associated to a particular point in the requested
|
123 | * GraphQL document, it should contain a list of locations.
|
124 | */
|
125 | readonly locations?: ReadonlyArray<SourceLocation>;
|
126 | /**
|
127 | * If an error can be associated to a particular field in the GraphQL result,
|
128 | * it _must_ contain an entry with the key `path` that details the path of
|
129 | * the response field which experienced the error. This allows clients to
|
130 | * identify whether a null result is intentional or caused by a runtime error.
|
131 | */
|
132 | readonly path?: ReadonlyArray<string | number>;
|
133 | /**
|
134 | * Reserved for implementors to extend the protocol however they see fit,
|
135 | * and hence there are no additional restrictions on its contents.
|
136 | */
|
137 | readonly extensions?: GraphQLFormattedErrorExtensions;
|
138 | }
|
139 | /**
|
140 | * Prints a GraphQLError to a string, representing useful location information
|
141 | * about the error's position in the source.
|
142 | *
|
143 | * @deprecated Please use `error.toString` instead. Will be removed in v17
|
144 | */
|
145 | export declare function printError(error: GraphQLError): string;
|
146 | /**
|
147 | * Given a GraphQLError, format it according to the rules described by the
|
148 | * Response Format, Errors section of the GraphQL Specification.
|
149 | *
|
150 | * @deprecated Please use `error.toJSON` instead. Will be removed in v17
|
151 | */
|
152 | export declare function formatError(error: GraphQLError): GraphQLFormattedError;
|