graphql 15.6.1 → 15.7.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 +16 -12
- package/error/GraphQLError.js +59 -96
- package/error/GraphQLError.js.flow +47 -96
- package/error/GraphQLError.mjs +58 -96
- package/error/formatError.js +1 -1
- package/error/formatError.js.flow +1 -1
- package/error/formatError.mjs +1 -1
- package/error/index.d.ts +5 -1
- package/index.d.ts +1 -0
- package/package.json +2 -2
- package/version.js +3 -3
- package/version.js.flow +3 -3
- package/version.mjs +3 -3
package/error/GraphQLError.d.ts
CHANGED
|
@@ -4,6 +4,19 @@ import { ASTNode } from '../language/ast';
|
|
|
4
4
|
import { Source } from '../language/source';
|
|
5
5
|
import { SourceLocation } from '../language/location';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Custom extensions
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Use a unique identifier name for your extension, for example the name of
|
|
12
|
+
* your library or project. Do not use a shortened identifier as this increases
|
|
13
|
+
* the risk of conflicts. We recommend you add at most one extension field,
|
|
14
|
+
* an object which can contain all the values you need.
|
|
15
|
+
*/
|
|
16
|
+
export interface GraphQLErrorExtensions {
|
|
17
|
+
[attributeName: string]: any;
|
|
18
|
+
}
|
|
19
|
+
|
|
7
20
|
/**
|
|
8
21
|
* A GraphQLError describes an Error found during the parse, validate, or
|
|
9
22
|
* execute phases of performing a GraphQL operation. In addition to a message
|
|
@@ -18,18 +31,9 @@ export class GraphQLError extends Error {
|
|
|
18
31
|
positions?: Maybe<ReadonlyArray<number>>,
|
|
19
32
|
path?: Maybe<ReadonlyArray<string | number>>,
|
|
20
33
|
originalError?: Maybe<Error>,
|
|
21
|
-
extensions?: Maybe<
|
|
34
|
+
extensions?: Maybe<GraphQLErrorExtensions>,
|
|
22
35
|
);
|
|
23
36
|
|
|
24
|
-
/**
|
|
25
|
-
* A message describing the Error for debugging purposes.
|
|
26
|
-
*
|
|
27
|
-
* Enumerable, and appears in the result of JSON.stringify().
|
|
28
|
-
*
|
|
29
|
-
* Note: should be treated as readonly, despite invariant usage.
|
|
30
|
-
*/
|
|
31
|
-
message: string;
|
|
32
|
-
|
|
33
37
|
/**
|
|
34
38
|
* An array of { line, column } locations within the source GraphQL document
|
|
35
39
|
* which correspond to this error.
|
|
@@ -72,12 +76,12 @@ export class GraphQLError extends Error {
|
|
|
72
76
|
/**
|
|
73
77
|
* The original error thrown from a field resolver during execution.
|
|
74
78
|
*/
|
|
75
|
-
readonly originalError:
|
|
79
|
+
readonly originalError: Error | undefined;
|
|
76
80
|
|
|
77
81
|
/**
|
|
78
82
|
* Extension fields to add to the formatted error.
|
|
79
83
|
*/
|
|
80
|
-
readonly extensions: { [key: string]: any }
|
|
84
|
+
readonly extensions: { [key: string]: any };
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
/**
|
package/error/GraphQLError.js
CHANGED
|
@@ -18,6 +18,12 @@ var _printLocation = require("../language/printLocation.js");
|
|
|
18
18
|
|
|
19
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
20
|
|
|
21
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
22
|
+
|
|
23
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
24
|
+
|
|
25
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
26
|
+
|
|
21
27
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
22
28
|
|
|
23
29
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -55,14 +61,6 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
55
61
|
|
|
56
62
|
var _super = _createSuper(GraphQLError);
|
|
57
63
|
|
|
58
|
-
/**
|
|
59
|
-
* A message describing the Error for debugging purposes.
|
|
60
|
-
*
|
|
61
|
-
* Enumerable, and appears in the result of JSON.stringify().
|
|
62
|
-
*
|
|
63
|
-
* Note: should be treated as readonly, despite invariant usage.
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
64
|
/**
|
|
67
65
|
* An array of { line, column } locations within the source GraphQL document
|
|
68
66
|
* which correspond to this error.
|
|
@@ -105,117 +103,78 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
105
103
|
* Extension fields to add to the formatted error.
|
|
106
104
|
*/
|
|
107
105
|
function GraphQLError(message, nodes, source, positions, path, originalError, extensions) {
|
|
108
|
-
var
|
|
106
|
+
var _nodeLocations, _nodeLocations2, _nodeLocations3;
|
|
109
107
|
|
|
110
108
|
var _this;
|
|
111
109
|
|
|
112
110
|
_classCallCheck(this, GraphQLError);
|
|
113
111
|
|
|
114
|
-
_this = _super.call(this, message);
|
|
112
|
+
_this = _super.call(this, message);
|
|
113
|
+
_this.name = 'GraphQLError';
|
|
114
|
+
_this.originalError = originalError !== null && originalError !== void 0 ? originalError : undefined; // Compute list of blame nodes.
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
_this.nodes = undefinedIfEmpty(Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined);
|
|
117
|
+
var nodeLocations = [];
|
|
117
118
|
|
|
119
|
+
for (var _i2 = 0, _ref3 = (_this$nodes = _this.nodes) !== null && _this$nodes !== void 0 ? _this$nodes : []; _i2 < _ref3.length; _i2++) {
|
|
120
|
+
var _this$nodes;
|
|
118
121
|
|
|
119
|
-
|
|
122
|
+
var _ref4 = _ref3[_i2];
|
|
123
|
+
var loc = _ref4.loc;
|
|
120
124
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
_source = (_nodes$0$loc = _nodes[0].loc) === null || _nodes$0$loc === void 0 ? void 0 : _nodes$0$loc.source;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
var _positions = positions;
|
|
128
|
-
|
|
129
|
-
if (!_positions && _nodes) {
|
|
130
|
-
_positions = _nodes.reduce(function (list, node) {
|
|
131
|
-
if (node.loc) {
|
|
132
|
-
list.push(node.loc.start);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return list;
|
|
136
|
-
}, []);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (_positions && _positions.length === 0) {
|
|
140
|
-
_positions = undefined;
|
|
125
|
+
if (loc != null) {
|
|
126
|
+
nodeLocations.push(loc);
|
|
127
|
+
}
|
|
141
128
|
}
|
|
142
129
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (positions && source) {
|
|
146
|
-
_locations = positions.map(function (pos) {
|
|
147
|
-
return (0, _location.getLocation)(source, pos);
|
|
148
|
-
});
|
|
149
|
-
} else if (_nodes) {
|
|
150
|
-
_locations = _nodes.reduce(function (list, node) {
|
|
151
|
-
if (node.loc) {
|
|
152
|
-
list.push((0, _location.getLocation)(node.loc.source, node.loc.start));
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return list;
|
|
156
|
-
}, []);
|
|
157
|
-
}
|
|
130
|
+
nodeLocations = undefinedIfEmpty(nodeLocations); // Compute locations in the source for the given nodes/positions.
|
|
158
131
|
|
|
159
|
-
|
|
132
|
+
_this.source = source !== null && source !== void 0 ? source : (_nodeLocations = nodeLocations) === null || _nodeLocations === void 0 ? void 0 : _nodeLocations[0].source;
|
|
133
|
+
_this.positions = positions !== null && positions !== void 0 ? positions : (_nodeLocations2 = nodeLocations) === null || _nodeLocations2 === void 0 ? void 0 : _nodeLocations2.map(function (loc) {
|
|
134
|
+
return loc.start;
|
|
135
|
+
});
|
|
136
|
+
_this.locations = positions && source ? positions.map(function (pos) {
|
|
137
|
+
return (0, _location.getLocation)(source, pos);
|
|
138
|
+
}) : (_nodeLocations3 = nodeLocations) === null || _nodeLocations3 === void 0 ? void 0 : _nodeLocations3.map(function (loc) {
|
|
139
|
+
return (0, _location.getLocation)(loc.source, loc.start);
|
|
140
|
+
});
|
|
141
|
+
_this.path = path !== null && path !== void 0 ? path : undefined;
|
|
142
|
+
_this.extensions = extensions !== null && extensions !== void 0 ? extensions : {};
|
|
143
|
+
var originalExtensions = originalError === null || originalError === void 0 ? void 0 : originalError.extensions;
|
|
160
144
|
|
|
161
|
-
if (
|
|
162
|
-
|
|
145
|
+
if ((0, _isObjectLike.default)(originalExtensions)) {
|
|
146
|
+
_this.extensions = _objectSpread({}, originalExtensions);
|
|
147
|
+
} // By being enumerable, JSON.stringify will include bellow properties in the resulting output.
|
|
148
|
+
// This ensures that the simplest possible GraphQL service adheres to the spec.
|
|
163
149
|
|
|
164
|
-
if ((0, _isObjectLike.default)(originalExtensions)) {
|
|
165
|
-
_extensions = originalExtensions;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
150
|
|
|
169
151
|
Object.defineProperties(_assertThisInitialized(_this), {
|
|
170
|
-
name: {
|
|
171
|
-
value: 'GraphQLError'
|
|
172
|
-
},
|
|
173
152
|
message: {
|
|
174
|
-
|
|
175
|
-
// By being enumerable, JSON.stringify will include `message` in the
|
|
176
|
-
// resulting output. This ensures that the simplest possible GraphQL
|
|
177
|
-
// service adheres to the spec.
|
|
178
|
-
enumerable: true,
|
|
179
|
-
writable: true
|
|
153
|
+
enumerable: true
|
|
180
154
|
},
|
|
181
155
|
locations: {
|
|
182
|
-
|
|
183
|
-
// in JSON.stringify() when not provided.
|
|
184
|
-
value: (_locations2 = _locations) !== null && _locations2 !== void 0 ? _locations2 : undefined,
|
|
185
|
-
// By being enumerable, JSON.stringify will include `locations` in the
|
|
186
|
-
// resulting output. This ensures that the simplest possible GraphQL
|
|
187
|
-
// service adheres to the spec.
|
|
188
|
-
enumerable: _locations != null
|
|
156
|
+
enumerable: _this.locations != null
|
|
189
157
|
},
|
|
190
158
|
path: {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
enumerable:
|
|
159
|
+
enumerable: _this.path != null
|
|
160
|
+
},
|
|
161
|
+
extensions: {
|
|
162
|
+
enumerable: _this.extensions != null && Object.keys(_this.extensions).length > 0
|
|
163
|
+
},
|
|
164
|
+
name: {
|
|
165
|
+
enumerable: false
|
|
198
166
|
},
|
|
199
167
|
nodes: {
|
|
200
|
-
|
|
168
|
+
enumerable: false
|
|
201
169
|
},
|
|
202
170
|
source: {
|
|
203
|
-
|
|
171
|
+
enumerable: false
|
|
204
172
|
},
|
|
205
173
|
positions: {
|
|
206
|
-
|
|
174
|
+
enumerable: false
|
|
207
175
|
},
|
|
208
176
|
originalError: {
|
|
209
|
-
|
|
210
|
-
},
|
|
211
|
-
extensions: {
|
|
212
|
-
// Coercing falsy values to undefined ensures they will not be included
|
|
213
|
-
// in JSON.stringify() when not provided.
|
|
214
|
-
value: (_extensions2 = _extensions) !== null && _extensions2 !== void 0 ? _extensions2 : undefined,
|
|
215
|
-
// By being enumerable, JSON.stringify will include `path` in the
|
|
216
|
-
// resulting output. This ensures that the simplest possible GraphQL
|
|
217
|
-
// service adheres to the spec.
|
|
218
|
-
enumerable: _extensions != null
|
|
177
|
+
enumerable: false
|
|
219
178
|
}
|
|
220
179
|
}); // Include (non-enumerable) stack trace.
|
|
221
180
|
|
|
@@ -258,28 +217,32 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
258
217
|
|
|
259
218
|
return GraphQLError;
|
|
260
219
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
220
|
+
|
|
221
|
+
exports.GraphQLError = GraphQLError;
|
|
222
|
+
|
|
223
|
+
function undefinedIfEmpty(array) {
|
|
224
|
+
return array === undefined || array.length === 0 ? undefined : array;
|
|
225
|
+
}
|
|
261
226
|
/**
|
|
262
227
|
* Prints a GraphQLError to a string, representing useful location information
|
|
263
228
|
* about the error's position in the source.
|
|
264
229
|
*/
|
|
265
230
|
|
|
266
231
|
|
|
267
|
-
exports.GraphQLError = GraphQLError;
|
|
268
|
-
|
|
269
232
|
function printError(error) {
|
|
270
233
|
var output = error.message;
|
|
271
234
|
|
|
272
235
|
if (error.nodes) {
|
|
273
|
-
for (var
|
|
274
|
-
var node = _error$nodes2[
|
|
236
|
+
for (var _i4 = 0, _error$nodes2 = error.nodes; _i4 < _error$nodes2.length; _i4++) {
|
|
237
|
+
var node = _error$nodes2[_i4];
|
|
275
238
|
|
|
276
239
|
if (node.loc) {
|
|
277
240
|
output += '\n\n' + (0, _printLocation.printLocation)(node.loc);
|
|
278
241
|
}
|
|
279
242
|
}
|
|
280
243
|
} else if (error.source && error.locations) {
|
|
281
|
-
for (var
|
|
282
|
-
var location = _error$locations2[
|
|
244
|
+
for (var _i6 = 0, _error$locations2 = error.locations; _i6 < _error$locations2.length; _i6++) {
|
|
245
|
+
var location = _error$locations2[_i6];
|
|
283
246
|
output += '\n\n' + (0, _printLocation.printSourceLocation)(error.source, location);
|
|
284
247
|
}
|
|
285
248
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
// @flow strict
|
|
2
|
-
// FIXME:
|
|
3
|
-
// flowlint uninitialized-instance-property:off
|
|
4
|
-
|
|
5
2
|
import isObjectLike from '../jsutils/isObjectLike';
|
|
6
3
|
import { SYMBOL_TO_STRING_TAG } from '../polyfills/symbols';
|
|
7
4
|
|
|
@@ -18,15 +15,6 @@ import { printLocation, printSourceLocation } from '../language/printLocation';
|
|
|
18
15
|
* GraphQL document and/or execution result that correspond to the Error.
|
|
19
16
|
*/
|
|
20
17
|
export class GraphQLError extends Error {
|
|
21
|
-
/**
|
|
22
|
-
* A message describing the Error for debugging purposes.
|
|
23
|
-
*
|
|
24
|
-
* Enumerable, and appears in the result of JSON.stringify().
|
|
25
|
-
*
|
|
26
|
-
* Note: should be treated as readonly, despite invariant usage.
|
|
27
|
-
*/
|
|
28
|
-
message: string;
|
|
29
|
-
|
|
30
18
|
/**
|
|
31
19
|
* An array of { line, column } locations within the source GraphQL document
|
|
32
20
|
* which correspond to this error.
|
|
@@ -69,12 +57,12 @@ export class GraphQLError extends Error {
|
|
|
69
57
|
/**
|
|
70
58
|
* The original error thrown from a field resolver during execution.
|
|
71
59
|
*/
|
|
72
|
-
+originalError:
|
|
60
|
+
+originalError: Error | void;
|
|
73
61
|
|
|
74
62
|
/**
|
|
75
63
|
* Extension fields to add to the formatted error.
|
|
76
64
|
*/
|
|
77
|
-
+extensions: { [key: string]: mixed, ... }
|
|
65
|
+
+extensions: { [key: string]: mixed, ... };
|
|
78
66
|
|
|
79
67
|
constructor(
|
|
80
68
|
message: string,
|
|
@@ -87,103 +75,60 @@ export class GraphQLError extends Error {
|
|
|
87
75
|
) {
|
|
88
76
|
super(message);
|
|
89
77
|
|
|
78
|
+
this.name = 'GraphQLError';
|
|
79
|
+
this.originalError = originalError ?? undefined;
|
|
80
|
+
|
|
90
81
|
// Compute list of blame nodes.
|
|
91
|
-
|
|
92
|
-
? nodes
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
82
|
+
this.nodes = undefinedIfEmpty(
|
|
83
|
+
Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
let nodeLocations = [];
|
|
87
|
+
for (const { loc } of this.nodes ?? []) {
|
|
88
|
+
if (loc != null) {
|
|
89
|
+
nodeLocations.push(loc);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
nodeLocations = undefinedIfEmpty(nodeLocations);
|
|
98
93
|
|
|
99
94
|
// Compute locations in the source for the given nodes/positions.
|
|
100
|
-
|
|
101
|
-
if (!_source && _nodes) {
|
|
102
|
-
_source = _nodes[0].loc?.source;
|
|
103
|
-
}
|
|
95
|
+
this.source = source ?? nodeLocations?.[0].source;
|
|
104
96
|
|
|
105
|
-
|
|
106
|
-
if (!_positions && _nodes) {
|
|
107
|
-
_positions = _nodes.reduce((list, node) => {
|
|
108
|
-
if (node.loc) {
|
|
109
|
-
list.push(node.loc.start);
|
|
110
|
-
}
|
|
111
|
-
return list;
|
|
112
|
-
}, []);
|
|
113
|
-
}
|
|
114
|
-
if (_positions && _positions.length === 0) {
|
|
115
|
-
_positions = undefined;
|
|
116
|
-
}
|
|
97
|
+
this.positions = positions ?? nodeLocations?.map((loc) => loc.start);
|
|
117
98
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
_locations = _nodes.reduce((list, node) => {
|
|
123
|
-
if (node.loc) {
|
|
124
|
-
list.push(getLocation(node.loc.source, node.loc.start));
|
|
125
|
-
}
|
|
126
|
-
return list;
|
|
127
|
-
}, []);
|
|
128
|
-
}
|
|
99
|
+
this.locations =
|
|
100
|
+
positions && source
|
|
101
|
+
? positions.map((pos) => getLocation(source, pos))
|
|
102
|
+
: nodeLocations?.map((loc) => getLocation(loc.source, loc.start));
|
|
129
103
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
104
|
+
this.path = path ?? undefined;
|
|
105
|
+
|
|
106
|
+
this.extensions = extensions ?? {};
|
|
107
|
+
|
|
108
|
+
const originalExtensions = originalError?.extensions;
|
|
109
|
+
if (isObjectLike(originalExtensions)) {
|
|
110
|
+
this.extensions = { ...originalExtensions };
|
|
136
111
|
}
|
|
137
112
|
|
|
113
|
+
// By being enumerable, JSON.stringify will include bellow properties in the resulting output.
|
|
114
|
+
// This ensures that the simplest possible GraphQL service adheres to the spec.
|
|
138
115
|
Object.defineProperties((this: any), {
|
|
139
|
-
|
|
140
|
-
message: {
|
|
141
|
-
value: message,
|
|
142
|
-
// By being enumerable, JSON.stringify will include `message` in the
|
|
143
|
-
// resulting output. This ensures that the simplest possible GraphQL
|
|
144
|
-
// service adheres to the spec.
|
|
145
|
-
enumerable: true,
|
|
146
|
-
writable: true,
|
|
147
|
-
},
|
|
116
|
+
message: { enumerable: true },
|
|
148
117
|
locations: {
|
|
149
|
-
|
|
150
|
-
// in JSON.stringify() when not provided.
|
|
151
|
-
value: _locations ?? undefined,
|
|
152
|
-
// By being enumerable, JSON.stringify will include `locations` in the
|
|
153
|
-
// resulting output. This ensures that the simplest possible GraphQL
|
|
154
|
-
// service adheres to the spec.
|
|
155
|
-
enumerable: _locations != null,
|
|
118
|
+
enumerable: this.locations != null,
|
|
156
119
|
},
|
|
157
120
|
path: {
|
|
158
|
-
|
|
159
|
-
// in JSON.stringify() when not provided.
|
|
160
|
-
value: path ?? undefined,
|
|
161
|
-
// By being enumerable, JSON.stringify will include `path` in the
|
|
162
|
-
// resulting output. This ensures that the simplest possible GraphQL
|
|
163
|
-
// service adheres to the spec.
|
|
164
|
-
enumerable: path != null,
|
|
165
|
-
},
|
|
166
|
-
nodes: {
|
|
167
|
-
value: _nodes ?? undefined,
|
|
168
|
-
},
|
|
169
|
-
source: {
|
|
170
|
-
value: _source ?? undefined,
|
|
171
|
-
},
|
|
172
|
-
positions: {
|
|
173
|
-
value: _positions ?? undefined,
|
|
174
|
-
},
|
|
175
|
-
originalError: {
|
|
176
|
-
value: originalError,
|
|
121
|
+
enumerable: this.path != null,
|
|
177
122
|
},
|
|
178
123
|
extensions: {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
value: _extensions ?? undefined,
|
|
182
|
-
// By being enumerable, JSON.stringify will include `path` in the
|
|
183
|
-
// resulting output. This ensures that the simplest possible GraphQL
|
|
184
|
-
// service adheres to the spec.
|
|
185
|
-
enumerable: _extensions != null,
|
|
124
|
+
enumerable:
|
|
125
|
+
this.extensions != null && Object.keys(this.extensions).length > 0,
|
|
186
126
|
},
|
|
127
|
+
name: { enumerable: false },
|
|
128
|
+
nodes: { enumerable: false },
|
|
129
|
+
source: { enumerable: false },
|
|
130
|
+
positions: { enumerable: false },
|
|
131
|
+
originalError: { enumerable: false },
|
|
187
132
|
});
|
|
188
133
|
|
|
189
134
|
// Include (non-enumerable) stack trace.
|
|
@@ -219,6 +164,12 @@ export class GraphQLError extends Error {
|
|
|
219
164
|
}
|
|
220
165
|
}
|
|
221
166
|
|
|
167
|
+
function undefinedIfEmpty<T>(
|
|
168
|
+
array: $ReadOnlyArray<T> | void,
|
|
169
|
+
): $ReadOnlyArray<T> | void {
|
|
170
|
+
return array === undefined || array.length === 0 ? undefined : array;
|
|
171
|
+
}
|
|
172
|
+
|
|
222
173
|
/**
|
|
223
174
|
* Prints a GraphQLError to a string, representing useful location information
|
|
224
175
|
* about the error's position in the source.
|
package/error/GraphQLError.mjs
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
2
|
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
+
|
|
7
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
|
|
3
9
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
10
|
|
|
5
11
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -26,8 +32,6 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
|
|
26
32
|
|
|
27
33
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
28
34
|
|
|
29
|
-
// FIXME:
|
|
30
|
-
// flowlint uninitialized-instance-property:off
|
|
31
35
|
import isObjectLike from "../jsutils/isObjectLike.mjs";
|
|
32
36
|
import { SYMBOL_TO_STRING_TAG } from "../polyfills/symbols.mjs";
|
|
33
37
|
import { getLocation } from "../language/location.mjs";
|
|
@@ -44,14 +48,6 @@ export var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
44
48
|
|
|
45
49
|
var _super = _createSuper(GraphQLError);
|
|
46
50
|
|
|
47
|
-
/**
|
|
48
|
-
* A message describing the Error for debugging purposes.
|
|
49
|
-
*
|
|
50
|
-
* Enumerable, and appears in the result of JSON.stringify().
|
|
51
|
-
*
|
|
52
|
-
* Note: should be treated as readonly, despite invariant usage.
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
51
|
/**
|
|
56
52
|
* An array of { line, column } locations within the source GraphQL document
|
|
57
53
|
* which correspond to this error.
|
|
@@ -94,117 +90,78 @@ export var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
94
90
|
* Extension fields to add to the formatted error.
|
|
95
91
|
*/
|
|
96
92
|
function GraphQLError(message, nodes, source, positions, path, originalError, extensions) {
|
|
97
|
-
var
|
|
93
|
+
var _nodeLocations, _nodeLocations2, _nodeLocations3;
|
|
98
94
|
|
|
99
95
|
var _this;
|
|
100
96
|
|
|
101
97
|
_classCallCheck(this, GraphQLError);
|
|
102
98
|
|
|
103
|
-
_this = _super.call(this, message);
|
|
99
|
+
_this = _super.call(this, message);
|
|
100
|
+
_this.name = 'GraphQLError';
|
|
101
|
+
_this.originalError = originalError !== null && originalError !== void 0 ? originalError : undefined; // Compute list of blame nodes.
|
|
104
102
|
|
|
105
|
-
|
|
103
|
+
_this.nodes = undefinedIfEmpty(Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined);
|
|
104
|
+
var nodeLocations = [];
|
|
106
105
|
|
|
106
|
+
for (var _i2 = 0, _ref3 = (_this$nodes = _this.nodes) !== null && _this$nodes !== void 0 ? _this$nodes : []; _i2 < _ref3.length; _i2++) {
|
|
107
|
+
var _this$nodes;
|
|
107
108
|
|
|
108
|
-
|
|
109
|
+
var _ref4 = _ref3[_i2];
|
|
110
|
+
var loc = _ref4.loc;
|
|
109
111
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
_source = (_nodes$0$loc = _nodes[0].loc) === null || _nodes$0$loc === void 0 ? void 0 : _nodes$0$loc.source;
|
|
112
|
+
if (loc != null) {
|
|
113
|
+
nodeLocations.push(loc);
|
|
114
|
+
}
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (!_positions && _nodes) {
|
|
119
|
-
_positions = _nodes.reduce(function (list, node) {
|
|
120
|
-
if (node.loc) {
|
|
121
|
-
list.push(node.loc.start);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return list;
|
|
125
|
-
}, []);
|
|
126
|
-
}
|
|
117
|
+
nodeLocations = undefinedIfEmpty(nodeLocations); // Compute locations in the source for the given nodes/positions.
|
|
127
118
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
119
|
+
_this.source = source !== null && source !== void 0 ? source : (_nodeLocations = nodeLocations) === null || _nodeLocations === void 0 ? void 0 : _nodeLocations[0].source;
|
|
120
|
+
_this.positions = positions !== null && positions !== void 0 ? positions : (_nodeLocations2 = nodeLocations) === null || _nodeLocations2 === void 0 ? void 0 : _nodeLocations2.map(function (loc) {
|
|
121
|
+
return loc.start;
|
|
122
|
+
});
|
|
123
|
+
_this.locations = positions && source ? positions.map(function (pos) {
|
|
124
|
+
return getLocation(source, pos);
|
|
125
|
+
}) : (_nodeLocations3 = nodeLocations) === null || _nodeLocations3 === void 0 ? void 0 : _nodeLocations3.map(function (loc) {
|
|
126
|
+
return getLocation(loc.source, loc.start);
|
|
127
|
+
});
|
|
128
|
+
_this.path = path !== null && path !== void 0 ? path : undefined;
|
|
129
|
+
_this.extensions = extensions !== null && extensions !== void 0 ? extensions : {};
|
|
130
|
+
var originalExtensions = originalError === null || originalError === void 0 ? void 0 : originalError.extensions;
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
if (isObjectLike(originalExtensions)) {
|
|
133
|
+
_this.extensions = _objectSpread({}, originalExtensions);
|
|
134
|
+
} // By being enumerable, JSON.stringify will include bellow properties in the resulting output.
|
|
135
|
+
// This ensures that the simplest possible GraphQL service adheres to the spec.
|
|
133
136
|
|
|
134
|
-
if (positions && source) {
|
|
135
|
-
_locations = positions.map(function (pos) {
|
|
136
|
-
return getLocation(source, pos);
|
|
137
|
-
});
|
|
138
|
-
} else if (_nodes) {
|
|
139
|
-
_locations = _nodes.reduce(function (list, node) {
|
|
140
|
-
if (node.loc) {
|
|
141
|
-
list.push(getLocation(node.loc.source, node.loc.start));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return list;
|
|
145
|
-
}, []);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
var _extensions = extensions;
|
|
149
|
-
|
|
150
|
-
if (_extensions == null && originalError != null) {
|
|
151
|
-
var originalExtensions = originalError.extensions;
|
|
152
|
-
|
|
153
|
-
if (isObjectLike(originalExtensions)) {
|
|
154
|
-
_extensions = originalExtensions;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
137
|
|
|
158
138
|
Object.defineProperties(_assertThisInitialized(_this), {
|
|
159
|
-
name: {
|
|
160
|
-
value: 'GraphQLError'
|
|
161
|
-
},
|
|
162
139
|
message: {
|
|
163
|
-
|
|
164
|
-
// By being enumerable, JSON.stringify will include `message` in the
|
|
165
|
-
// resulting output. This ensures that the simplest possible GraphQL
|
|
166
|
-
// service adheres to the spec.
|
|
167
|
-
enumerable: true,
|
|
168
|
-
writable: true
|
|
140
|
+
enumerable: true
|
|
169
141
|
},
|
|
170
142
|
locations: {
|
|
171
|
-
|
|
172
|
-
// in JSON.stringify() when not provided.
|
|
173
|
-
value: (_locations2 = _locations) !== null && _locations2 !== void 0 ? _locations2 : undefined,
|
|
174
|
-
// By being enumerable, JSON.stringify will include `locations` in the
|
|
175
|
-
// resulting output. This ensures that the simplest possible GraphQL
|
|
176
|
-
// service adheres to the spec.
|
|
177
|
-
enumerable: _locations != null
|
|
143
|
+
enumerable: _this.locations != null
|
|
178
144
|
},
|
|
179
145
|
path: {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
enumerable:
|
|
146
|
+
enumerable: _this.path != null
|
|
147
|
+
},
|
|
148
|
+
extensions: {
|
|
149
|
+
enumerable: _this.extensions != null && Object.keys(_this.extensions).length > 0
|
|
150
|
+
},
|
|
151
|
+
name: {
|
|
152
|
+
enumerable: false
|
|
187
153
|
},
|
|
188
154
|
nodes: {
|
|
189
|
-
|
|
155
|
+
enumerable: false
|
|
190
156
|
},
|
|
191
157
|
source: {
|
|
192
|
-
|
|
158
|
+
enumerable: false
|
|
193
159
|
},
|
|
194
160
|
positions: {
|
|
195
|
-
|
|
161
|
+
enumerable: false
|
|
196
162
|
},
|
|
197
163
|
originalError: {
|
|
198
|
-
|
|
199
|
-
},
|
|
200
|
-
extensions: {
|
|
201
|
-
// Coercing falsy values to undefined ensures they will not be included
|
|
202
|
-
// in JSON.stringify() when not provided.
|
|
203
|
-
value: (_extensions2 = _extensions) !== null && _extensions2 !== void 0 ? _extensions2 : undefined,
|
|
204
|
-
// By being enumerable, JSON.stringify will include `path` in the
|
|
205
|
-
// resulting output. This ensures that the simplest possible GraphQL
|
|
206
|
-
// service adheres to the spec.
|
|
207
|
-
enumerable: _extensions != null
|
|
164
|
+
enumerable: false
|
|
208
165
|
}
|
|
209
166
|
}); // Include (non-enumerable) stack trace.
|
|
210
167
|
|
|
@@ -247,25 +204,30 @@ export var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
247
204
|
|
|
248
205
|
return GraphQLError;
|
|
249
206
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
207
|
+
|
|
208
|
+
function undefinedIfEmpty(array) {
|
|
209
|
+
return array === undefined || array.length === 0 ? undefined : array;
|
|
210
|
+
}
|
|
250
211
|
/**
|
|
251
212
|
* Prints a GraphQLError to a string, representing useful location information
|
|
252
213
|
* about the error's position in the source.
|
|
253
214
|
*/
|
|
254
215
|
|
|
216
|
+
|
|
255
217
|
export function printError(error) {
|
|
256
218
|
var output = error.message;
|
|
257
219
|
|
|
258
220
|
if (error.nodes) {
|
|
259
|
-
for (var
|
|
260
|
-
var node = _error$nodes2[
|
|
221
|
+
for (var _i4 = 0, _error$nodes2 = error.nodes; _i4 < _error$nodes2.length; _i4++) {
|
|
222
|
+
var node = _error$nodes2[_i4];
|
|
261
223
|
|
|
262
224
|
if (node.loc) {
|
|
263
225
|
output += '\n\n' + printLocation(node.loc);
|
|
264
226
|
}
|
|
265
227
|
}
|
|
266
228
|
} else if (error.source && error.locations) {
|
|
267
|
-
for (var
|
|
268
|
-
var location = _error$locations2[
|
|
229
|
+
for (var _i6 = 0, _error$locations2 = error.locations; _i6 < _error$locations2.length; _i6++) {
|
|
230
|
+
var location = _error$locations2[_i6];
|
|
269
231
|
output += '\n\n' + printSourceLocation(error.source, location);
|
|
270
232
|
}
|
|
271
233
|
}
|
package/error/formatError.js
CHANGED
|
@@ -21,7 +21,7 @@ function formatError(error) {
|
|
|
21
21
|
var locations = error.locations;
|
|
22
22
|
var path = error.path;
|
|
23
23
|
var extensions = error.extensions;
|
|
24
|
-
return extensions ? {
|
|
24
|
+
return extensions && Object.keys(extensions).length > 0 ? {
|
|
25
25
|
message: message,
|
|
26
26
|
locations: locations,
|
|
27
27
|
path: path,
|
|
@@ -16,7 +16,7 @@ export function formatError(error: GraphQLError): GraphQLFormattedError {
|
|
|
16
16
|
const path = error.path;
|
|
17
17
|
const extensions = error.extensions;
|
|
18
18
|
|
|
19
|
-
return extensions
|
|
19
|
+
return extensions && Object.keys(extensions).length > 0
|
|
20
20
|
? { message, locations, path, extensions }
|
|
21
21
|
: { message, locations, path };
|
|
22
22
|
}
|
package/error/formatError.mjs
CHANGED
|
@@ -12,7 +12,7 @@ export function formatError(error) {
|
|
|
12
12
|
var locations = error.locations;
|
|
13
13
|
var path = error.path;
|
|
14
14
|
var extensions = error.extensions;
|
|
15
|
-
return extensions ? {
|
|
15
|
+
return extensions && Object.keys(extensions).length > 0 ? {
|
|
16
16
|
message: message,
|
|
17
17
|
locations: locations,
|
|
18
18
|
path: path,
|
package/error/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {
|
|
2
|
+
GraphQLError,
|
|
3
|
+
GraphQLErrorExtensions,
|
|
4
|
+
printError,
|
|
5
|
+
} from './GraphQLError';
|
|
2
6
|
export { syntaxError } from './syntaxError';
|
|
3
7
|
export { locatedError } from './locatedError';
|
|
4
8
|
export { formatError, GraphQLFormattedError } from './formatError';
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphql",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.7.0",
|
|
4
4
|
"description": "A Query Language and Runtime which can target any service.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index",
|
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">= 10.x"
|
|
24
24
|
}
|
|
25
|
-
}
|
|
25
|
+
}
|
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.7.0';
|
|
17
17
|
/**
|
|
18
18
|
* An object containing the components of the GraphQL.js version string
|
|
19
19
|
*/
|
|
@@ -21,8 +21,8 @@ var version = '15.6.1';
|
|
|
21
21
|
exports.version = version;
|
|
22
22
|
var versionInfo = Object.freeze({
|
|
23
23
|
major: 15,
|
|
24
|
-
minor:
|
|
25
|
-
patch:
|
|
24
|
+
minor: 7,
|
|
25
|
+
patch: 0,
|
|
26
26
|
preReleaseTag: null
|
|
27
27
|
});
|
|
28
28
|
exports.versionInfo = versionInfo;
|
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.7.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:
|
|
18
|
-
patch:
|
|
17
|
+
minor: 7,
|
|
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.7.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:
|
|
17
|
-
patch:
|
|
16
|
+
minor: 7,
|
|
17
|
+
patch: 0,
|
|
18
18
|
preReleaseTag: null
|
|
19
19
|
});
|