graphql 15.9.0 → 15.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/error/GraphQLError.d.ts +41 -0
- package/error/GraphQLError.js +36 -0
- package/error/GraphQLError.js.flow +50 -0
- package/error/GraphQLError.mjs +33 -0
- package/error/formatError.d.ts +1 -40
- package/error/formatError.js +13 -31
- package/error/formatError.js.flow +1 -50
- package/error/formatError.mjs +1 -28
- package/package.json +1 -1
- package/version.js +2 -2
- package/version.js.flow +2 -2
- package/version.mjs +2 -2
package/error/GraphQLError.d.ts
CHANGED
|
@@ -82,6 +82,10 @@ export class GraphQLError extends Error {
|
|
|
82
82
|
* Extension fields to add to the formatted error.
|
|
83
83
|
*/
|
|
84
84
|
readonly extensions: { [key: string]: any };
|
|
85
|
+
|
|
86
|
+
toString(): string;
|
|
87
|
+
|
|
88
|
+
toJSON(): GraphQLFormattedError;
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
/**
|
|
@@ -89,3 +93,40 @@ export class GraphQLError extends Error {
|
|
|
89
93
|
* about the error's position in the source.
|
|
90
94
|
*/
|
|
91
95
|
export function printError(error: GraphQLError): string;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Given a GraphQLError, format it according to the rules described by the
|
|
99
|
+
* Response Format, Errors section of the GraphQL Specification.
|
|
100
|
+
*/
|
|
101
|
+
export function formatError(error: GraphQLError): GraphQLFormattedError;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
|
|
105
|
+
*/
|
|
106
|
+
export interface GraphQLFormattedError<
|
|
107
|
+
TExtensions extends Record<string, any> = Record<string, any>
|
|
108
|
+
> {
|
|
109
|
+
/**
|
|
110
|
+
* A short, human-readable summary of the problem that **SHOULD NOT** change
|
|
111
|
+
* from occurrence to occurrence of the problem, except for purposes of
|
|
112
|
+
* localization.
|
|
113
|
+
*/
|
|
114
|
+
readonly message: string;
|
|
115
|
+
/**
|
|
116
|
+
* If an error can be associated to a particular point in the requested
|
|
117
|
+
* GraphQL document, it should contain a list of locations.
|
|
118
|
+
*/
|
|
119
|
+
readonly locations?: ReadonlyArray<SourceLocation>;
|
|
120
|
+
/**
|
|
121
|
+
* If an error can be associated to a particular field in the GraphQL result,
|
|
122
|
+
* it _must_ contain an entry with the key `path` that details the path of
|
|
123
|
+
* the response field which experienced the error. This allows clients to
|
|
124
|
+
* identify whether a null result is intentional or caused by a runtime error.
|
|
125
|
+
*/
|
|
126
|
+
readonly path?: ReadonlyArray<string | number>;
|
|
127
|
+
/**
|
|
128
|
+
* Reserved for implementors to extend the protocol however they see fit,
|
|
129
|
+
* and hence there are no additional restrictions on its contents.
|
|
130
|
+
*/
|
|
131
|
+
readonly extensions?: TExtensions;
|
|
132
|
+
}
|
package/error/GraphQLError.js
CHANGED
|
@@ -6,8 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.printError = printError;
|
|
9
|
+
exports.formatError = formatError;
|
|
9
10
|
exports.GraphQLError = void 0;
|
|
10
11
|
|
|
12
|
+
var _devAssert = _interopRequireDefault(require("../jsutils/devAssert.js"));
|
|
13
|
+
|
|
11
14
|
var _isObjectLike = _interopRequireDefault(require("../jsutils/isObjectLike.js"));
|
|
12
15
|
|
|
13
16
|
var _symbols = require("../polyfills/symbols.js");
|
|
@@ -206,6 +209,11 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
206
209
|
key: "toString",
|
|
207
210
|
value: function toString() {
|
|
208
211
|
return printError(this);
|
|
212
|
+
}
|
|
213
|
+
}, {
|
|
214
|
+
key: "toJSON",
|
|
215
|
+
value: function toJSON() {
|
|
216
|
+
return formatError(this);
|
|
209
217
|
} // FIXME: workaround to not break chai comparisons, should be remove in v16
|
|
210
218
|
// $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
|
|
211
219
|
|
|
@@ -250,3 +258,31 @@ function printError(error) {
|
|
|
250
258
|
|
|
251
259
|
return output;
|
|
252
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Given a GraphQLError, format it according to the rules described by the
|
|
263
|
+
* Response Format, Errors section of the GraphQL Specification.
|
|
264
|
+
*/
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
function formatError(error) {
|
|
268
|
+
var _error$message;
|
|
269
|
+
|
|
270
|
+
error || (0, _devAssert.default)(0, 'Received null or undefined error.');
|
|
271
|
+
var message = (_error$message = error.message) !== null && _error$message !== void 0 ? _error$message : 'An unknown error occurred.';
|
|
272
|
+
var locations = error.locations;
|
|
273
|
+
var path = error.path;
|
|
274
|
+
var extensions = error.extensions;
|
|
275
|
+
return extensions && Object.keys(extensions).length > 0 ? {
|
|
276
|
+
message: message,
|
|
277
|
+
locations: locations,
|
|
278
|
+
path: path,
|
|
279
|
+
extensions: extensions
|
|
280
|
+
} : {
|
|
281
|
+
message: message,
|
|
282
|
+
locations: locations,
|
|
283
|
+
path: path
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
|
|
288
|
+
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// @flow strict
|
|
2
|
+
import devAssert from '../jsutils/devAssert';
|
|
2
3
|
import isObjectLike from '../jsutils/isObjectLike';
|
|
3
4
|
import { SYMBOL_TO_STRING_TAG } from '../polyfills/symbols';
|
|
4
5
|
|
|
@@ -158,6 +159,10 @@ export class GraphQLError extends Error {
|
|
|
158
159
|
return printError(this);
|
|
159
160
|
}
|
|
160
161
|
|
|
162
|
+
toJSON(): GraphQLFormattedError {
|
|
163
|
+
return formatError(this);
|
|
164
|
+
}
|
|
165
|
+
|
|
161
166
|
// FIXME: workaround to not break chai comparisons, should be remove in v16
|
|
162
167
|
// $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
|
|
163
168
|
get [SYMBOL_TO_STRING_TAG](): string {
|
|
@@ -192,3 +197,48 @@ export function printError(error: GraphQLError): string {
|
|
|
192
197
|
|
|
193
198
|
return output;
|
|
194
199
|
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Given a GraphQLError, format it according to the rules described by the
|
|
203
|
+
* Response Format, Errors section of the GraphQL Specification.
|
|
204
|
+
*/
|
|
205
|
+
export function formatError(error: GraphQLError): GraphQLFormattedError {
|
|
206
|
+
devAssert(error, 'Received null or undefined error.');
|
|
207
|
+
const message = error.message ?? 'An unknown error occurred.';
|
|
208
|
+
const locations = error.locations;
|
|
209
|
+
const path = error.path;
|
|
210
|
+
const extensions = error.extensions;
|
|
211
|
+
|
|
212
|
+
return extensions && Object.keys(extensions).length > 0
|
|
213
|
+
? { message, locations, path, extensions }
|
|
214
|
+
: { message, locations, path };
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
|
|
219
|
+
*/
|
|
220
|
+
export type GraphQLFormattedError = {|
|
|
221
|
+
/**
|
|
222
|
+
* A short, human-readable summary of the problem that **SHOULD NOT** change
|
|
223
|
+
* from occurrence to occurrence of the problem, except for purposes of
|
|
224
|
+
* localization.
|
|
225
|
+
*/
|
|
226
|
+
+message: string,
|
|
227
|
+
/**
|
|
228
|
+
* If an error can be associated to a particular point in the requested
|
|
229
|
+
* GraphQL document, it should contain a list of locations.
|
|
230
|
+
*/
|
|
231
|
+
+locations: $ReadOnlyArray<SourceLocation> | void,
|
|
232
|
+
/**
|
|
233
|
+
* If an error can be associated to a particular field in the GraphQL result,
|
|
234
|
+
* it _must_ contain an entry with the key `path` that details the path of
|
|
235
|
+
* the response field which experienced the error. This allows clients to
|
|
236
|
+
* identify whether a null result is intentional or caused by a runtime error.
|
|
237
|
+
*/
|
|
238
|
+
+path: $ReadOnlyArray<string | number> | void,
|
|
239
|
+
/**
|
|
240
|
+
* Reserved for implementors to extend the protocol however they see fit,
|
|
241
|
+
* and hence there are no additional restrictions on its contents.
|
|
242
|
+
*/
|
|
243
|
+
+extensions?: { [key: string]: mixed, ... },
|
|
244
|
+
|};
|
package/error/GraphQLError.mjs
CHANGED
|
@@ -32,6 +32,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
|
|
32
32
|
|
|
33
33
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
34
34
|
|
|
35
|
+
import devAssert from "../jsutils/devAssert.mjs";
|
|
35
36
|
import isObjectLike from "../jsutils/isObjectLike.mjs";
|
|
36
37
|
import { SYMBOL_TO_STRING_TAG } from "../polyfills/symbols.mjs";
|
|
37
38
|
import { getLocation } from "../language/location.mjs";
|
|
@@ -193,6 +194,11 @@ export var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
193
194
|
key: "toString",
|
|
194
195
|
value: function toString() {
|
|
195
196
|
return printError(this);
|
|
197
|
+
}
|
|
198
|
+
}, {
|
|
199
|
+
key: "toJSON",
|
|
200
|
+
value: function toJSON() {
|
|
201
|
+
return formatError(this);
|
|
196
202
|
} // FIXME: workaround to not break chai comparisons, should be remove in v16
|
|
197
203
|
// $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
|
|
198
204
|
|
|
@@ -235,3 +241,30 @@ export function printError(error) {
|
|
|
235
241
|
|
|
236
242
|
return output;
|
|
237
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Given a GraphQLError, format it according to the rules described by the
|
|
246
|
+
* Response Format, Errors section of the GraphQL Specification.
|
|
247
|
+
*/
|
|
248
|
+
|
|
249
|
+
export function formatError(error) {
|
|
250
|
+
var _error$message;
|
|
251
|
+
|
|
252
|
+
error || devAssert(0, 'Received null or undefined error.');
|
|
253
|
+
var message = (_error$message = error.message) !== null && _error$message !== void 0 ? _error$message : 'An unknown error occurred.';
|
|
254
|
+
var locations = error.locations;
|
|
255
|
+
var path = error.path;
|
|
256
|
+
var extensions = error.extensions;
|
|
257
|
+
return extensions && Object.keys(extensions).length > 0 ? {
|
|
258
|
+
message: message,
|
|
259
|
+
locations: locations,
|
|
260
|
+
path: path,
|
|
261
|
+
extensions: extensions
|
|
262
|
+
} : {
|
|
263
|
+
message: message,
|
|
264
|
+
locations: locations,
|
|
265
|
+
path: path
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
|
|
270
|
+
*/
|
package/error/formatError.d.ts
CHANGED
|
@@ -1,40 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { GraphQLError } from './GraphQLError';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Given a GraphQLError, format it according to the rules described by the
|
|
7
|
-
* Response Format, Errors section of the GraphQL Specification.
|
|
8
|
-
*/
|
|
9
|
-
export function formatError(error: GraphQLError): GraphQLFormattedError;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
|
|
13
|
-
*/
|
|
14
|
-
export interface GraphQLFormattedError<
|
|
15
|
-
TExtensions extends Record<string, any> = Record<string, any>
|
|
16
|
-
> {
|
|
17
|
-
/**
|
|
18
|
-
* A short, human-readable summary of the problem that **SHOULD NOT** change
|
|
19
|
-
* from occurrence to occurrence of the problem, except for purposes of
|
|
20
|
-
* localization.
|
|
21
|
-
*/
|
|
22
|
-
readonly message: string;
|
|
23
|
-
/**
|
|
24
|
-
* If an error can be associated to a particular point in the requested
|
|
25
|
-
* GraphQL document, it should contain a list of locations.
|
|
26
|
-
*/
|
|
27
|
-
readonly locations?: ReadonlyArray<SourceLocation>;
|
|
28
|
-
/**
|
|
29
|
-
* If an error can be associated to a particular field in the GraphQL result,
|
|
30
|
-
* it _must_ contain an entry with the key `path` that details the path of
|
|
31
|
-
* the response field which experienced the error. This allows clients to
|
|
32
|
-
* identify whether a null result is intentional or caused by a runtime error.
|
|
33
|
-
*/
|
|
34
|
-
readonly path?: ReadonlyArray<string | number>;
|
|
35
|
-
/**
|
|
36
|
-
* Reserved for implementors to extend the protocol however they see fit,
|
|
37
|
-
* and hence there are no additional restrictions on its contents.
|
|
38
|
-
*/
|
|
39
|
-
readonly extensions?: TExtensions;
|
|
40
|
-
}
|
|
1
|
+
export { formatError, GraphQLFormattedError } from './GraphQLError';
|
package/error/formatError.js
CHANGED
|
@@ -3,35 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
Object.defineProperty(exports, "formatError", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _GraphQLError.formatError;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "GraphQLFormattedError", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _GraphQLError.GraphQLFormattedError;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
var message = (_error$message = error.message) !== null && _error$message !== void 0 ? _error$message : 'An unknown error occurred.';
|
|
21
|
-
var locations = error.locations;
|
|
22
|
-
var path = error.path;
|
|
23
|
-
var extensions = error.extensions;
|
|
24
|
-
return extensions && Object.keys(extensions).length > 0 ? {
|
|
25
|
-
message: message,
|
|
26
|
-
locations: locations,
|
|
27
|
-
path: path,
|
|
28
|
-
extensions: extensions
|
|
29
|
-
} : {
|
|
30
|
-
message: message,
|
|
31
|
-
locations: locations,
|
|
32
|
-
path: path
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
|
|
37
|
-
*/
|
|
19
|
+
var _GraphQLError = require("./GraphQLError.js");
|
|
@@ -1,51 +1,2 @@
|
|
|
1
1
|
// @flow strict
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import type { SourceLocation } from '../language/location';
|
|
5
|
-
|
|
6
|
-
import type { GraphQLError } from './GraphQLError';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Given a GraphQLError, format it according to the rules described by the
|
|
10
|
-
* Response Format, Errors section of the GraphQL Specification.
|
|
11
|
-
*/
|
|
12
|
-
export function formatError(error: GraphQLError): GraphQLFormattedError {
|
|
13
|
-
devAssert(error, 'Received null or undefined error.');
|
|
14
|
-
const message = error.message ?? 'An unknown error occurred.';
|
|
15
|
-
const locations = error.locations;
|
|
16
|
-
const path = error.path;
|
|
17
|
-
const extensions = error.extensions;
|
|
18
|
-
|
|
19
|
-
return extensions && Object.keys(extensions).length > 0
|
|
20
|
-
? { message, locations, path, extensions }
|
|
21
|
-
: { message, locations, path };
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
|
|
26
|
-
*/
|
|
27
|
-
export type GraphQLFormattedError = {|
|
|
28
|
-
/**
|
|
29
|
-
* A short, human-readable summary of the problem that **SHOULD NOT** change
|
|
30
|
-
* from occurrence to occurrence of the problem, except for purposes of
|
|
31
|
-
* localization.
|
|
32
|
-
*/
|
|
33
|
-
+message: string,
|
|
34
|
-
/**
|
|
35
|
-
* If an error can be associated to a particular point in the requested
|
|
36
|
-
* GraphQL document, it should contain a list of locations.
|
|
37
|
-
*/
|
|
38
|
-
+locations: $ReadOnlyArray<SourceLocation> | void,
|
|
39
|
-
/**
|
|
40
|
-
* If an error can be associated to a particular field in the GraphQL result,
|
|
41
|
-
* it _must_ contain an entry with the key `path` that details the path of
|
|
42
|
-
* the response field which experienced the error. This allows clients to
|
|
43
|
-
* identify whether a null result is intentional or caused by a runtime error.
|
|
44
|
-
*/
|
|
45
|
-
+path: $ReadOnlyArray<string | number> | void,
|
|
46
|
-
/**
|
|
47
|
-
* Reserved for implementors to extend the protocol however they see fit,
|
|
48
|
-
* and hence there are no additional restrictions on its contents.
|
|
49
|
-
*/
|
|
50
|
-
+extensions?: { [key: string]: mixed, ... },
|
|
51
|
-
|};
|
|
2
|
+
export { formatError, GraphQLFormattedError } from './GraphQLError';
|
package/error/formatError.mjs
CHANGED
|
@@ -1,28 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Given a GraphQLError, format it according to the rules described by the
|
|
5
|
-
* Response Format, Errors section of the GraphQL Specification.
|
|
6
|
-
*/
|
|
7
|
-
export function formatError(error) {
|
|
8
|
-
var _error$message;
|
|
9
|
-
|
|
10
|
-
error || devAssert(0, 'Received null or undefined error.');
|
|
11
|
-
var message = (_error$message = error.message) !== null && _error$message !== void 0 ? _error$message : 'An unknown error occurred.';
|
|
12
|
-
var locations = error.locations;
|
|
13
|
-
var path = error.path;
|
|
14
|
-
var extensions = error.extensions;
|
|
15
|
-
return extensions && Object.keys(extensions).length > 0 ? {
|
|
16
|
-
message: message,
|
|
17
|
-
locations: locations,
|
|
18
|
-
path: path,
|
|
19
|
-
extensions: extensions
|
|
20
|
-
} : {
|
|
21
|
-
message: message,
|
|
22
|
-
locations: locations,
|
|
23
|
-
path: path
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
|
|
28
|
-
*/
|
|
1
|
+
export { formatError, GraphQLFormattedError } from "./GraphQLError.mjs";
|
package/package.json
CHANGED
package/version.js
CHANGED
|
@@ -13,7 +13,7 @@ exports.versionInfo = exports.version = void 0;
|
|
|
13
13
|
/**
|
|
14
14
|
* A string containing the version of the GraphQL.js library
|
|
15
15
|
*/
|
|
16
|
-
var version = '15.
|
|
16
|
+
var version = '15.10.0';
|
|
17
17
|
/**
|
|
18
18
|
* An object containing the components of the GraphQL.js version string
|
|
19
19
|
*/
|
|
@@ -21,7 +21,7 @@ var version = '15.9.0';
|
|
|
21
21
|
exports.version = version;
|
|
22
22
|
var versionInfo = Object.freeze({
|
|
23
23
|
major: 15,
|
|
24
|
-
minor:
|
|
24
|
+
minor: 10,
|
|
25
25
|
patch: 0,
|
|
26
26
|
preReleaseTag: null
|
|
27
27
|
});
|
package/version.js.flow
CHANGED
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
/**
|
|
8
8
|
* A string containing the version of the GraphQL.js library
|
|
9
9
|
*/
|
|
10
|
-
export const version = '15.
|
|
10
|
+
export const version = '15.10.0';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* An object containing the components of the GraphQL.js version string
|
|
14
14
|
*/
|
|
15
15
|
export const versionInfo = Object.freeze({
|
|
16
16
|
major: 15,
|
|
17
|
-
minor:
|
|
17
|
+
minor: 10,
|
|
18
18
|
patch: 0,
|
|
19
19
|
preReleaseTag: null,
|
|
20
20
|
});
|
package/version.mjs
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* A string containing the version of the GraphQL.js library
|
|
8
8
|
*/
|
|
9
|
-
export var version = '15.
|
|
9
|
+
export var version = '15.10.0';
|
|
10
10
|
/**
|
|
11
11
|
* An object containing the components of the GraphQL.js version string
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
export var versionInfo = Object.freeze({
|
|
15
15
|
major: 15,
|
|
16
|
-
minor:
|
|
16
|
+
minor: 10,
|
|
17
17
|
patch: 0,
|
|
18
18
|
preReleaseTag: null
|
|
19
19
|
});
|