graphql 16.3.0 → 16.5.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 +4 -4
- package/error/GraphQLError.js +4 -4
- package/error/GraphQLError.mjs +4 -4
- package/error/index.d.ts +1 -0
- package/error/locatedError.js +8 -8
- package/error/locatedError.mjs +8 -8
- package/error/syntaxError.js +3 -5
- package/error/syntaxError.mjs +4 -3
- package/execution/execute.js +15 -5
- package/execution/execute.mjs +15 -5
- package/execution/index.d.ts +5 -1
- package/execution/index.js +6 -0
- package/execution/index.mjs +5 -1
- package/execution/subscribe.js +6 -2
- package/execution/subscribe.mjs +6 -2
- package/execution/values.d.ts +0 -2
- package/execution/values.js +25 -17
- package/execution/values.mjs +25 -17
- package/index.d.ts +2 -0
- package/index.js +6 -0
- package/index.mjs +1 -0
- package/jsutils/instanceOf.js +2 -1
- package/jsutils/instanceOf.mjs +2 -1
- package/package.json +2 -2
- package/type/definition.d.ts +12 -6
- package/type/definition.js +18 -8
- package/type/definition.mjs +18 -8
- package/type/scalars.js +15 -5
- package/type/scalars.mjs +15 -5
- package/type/validate.js +5 -1
- package/type/validate.mjs +5 -1
- package/utilities/coerceInputValue.js +3 -5
- package/utilities/coerceInputValue.mjs +3 -8
- package/utilities/getOperationRootType.js +12 -4
- package/utilities/getOperationRootType.mjs +12 -10
- package/validation/rules/ExecutableDefinitionsRule.js +3 -1
- package/validation/rules/ExecutableDefinitionsRule.mjs +3 -4
- package/validation/rules/FieldsOnCorrectTypeRule.js +3 -1
- package/validation/rules/FieldsOnCorrectTypeRule.mjs +3 -1
- package/validation/rules/FragmentsOnCompositeTypesRule.js +6 -2
- package/validation/rules/FragmentsOnCompositeTypesRule.mjs +6 -2
- package/validation/rules/KnownArgumentNamesRule.js +6 -2
- package/validation/rules/KnownArgumentNamesRule.mjs +6 -2
- package/validation/rules/KnownDirectivesRule.js +6 -2
- package/validation/rules/KnownDirectivesRule.mjs +6 -2
- package/validation/rules/KnownFragmentNamesRule.js +3 -1
- package/validation/rules/KnownFragmentNamesRule.mjs +3 -1
- package/validation/rules/KnownTypeNamesRule.js +3 -1
- package/validation/rules/KnownTypeNamesRule.mjs +3 -1
- package/validation/rules/LoneAnonymousOperationRule.js +3 -1
- package/validation/rules/LoneAnonymousOperationRule.mjs +3 -1
- package/validation/rules/LoneSchemaDefinitionRule.js +6 -2
- package/validation/rules/LoneSchemaDefinitionRule.mjs +6 -2
- package/validation/rules/NoFragmentCyclesRule.js +3 -1
- package/validation/rules/NoFragmentCyclesRule.mjs +3 -1
- package/validation/rules/NoUndefinedVariablesRule.js +3 -1
- package/validation/rules/NoUndefinedVariablesRule.mjs +3 -1
- package/validation/rules/NoUnusedFragmentsRule.js +3 -1
- package/validation/rules/NoUnusedFragmentsRule.mjs +3 -4
- package/validation/rules/NoUnusedVariablesRule.js +3 -1
- package/validation/rules/NoUnusedVariablesRule.mjs +3 -1
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js +3 -1
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +3 -1
- package/validation/rules/PossibleFragmentSpreadsRule.js +6 -2
- package/validation/rules/PossibleFragmentSpreadsRule.mjs +6 -2
- package/validation/rules/PossibleTypeExtensionsRule.js +6 -2
- package/validation/rules/PossibleTypeExtensionsRule.mjs +6 -5
- package/validation/rules/ProvidedRequiredArgumentsRule.js +6 -2
- package/validation/rules/ProvidedRequiredArgumentsRule.mjs +6 -2
- package/validation/rules/ScalarLeafsRule.js +6 -2
- package/validation/rules/ScalarLeafsRule.mjs +6 -2
- package/validation/rules/SingleFieldSubscriptionsRule.js +6 -2
- package/validation/rules/SingleFieldSubscriptionsRule.mjs +6 -2
- package/validation/rules/UniqueArgumentDefinitionNamesRule.js +3 -1
- package/validation/rules/UniqueArgumentDefinitionNamesRule.mjs +3 -1
- package/validation/rules/UniqueArgumentNamesRule.js +3 -1
- package/validation/rules/UniqueArgumentNamesRule.mjs +3 -1
- package/validation/rules/UniqueDirectiveNamesRule.js +6 -2
- package/validation/rules/UniqueDirectiveNamesRule.mjs +6 -2
- package/validation/rules/UniqueDirectivesPerLocationRule.js +3 -1
- package/validation/rules/UniqueDirectivesPerLocationRule.mjs +3 -1
- package/validation/rules/UniqueEnumValueNamesRule.js +6 -2
- package/validation/rules/UniqueEnumValueNamesRule.mjs +6 -2
- package/validation/rules/UniqueFieldDefinitionNamesRule.js +6 -2
- package/validation/rules/UniqueFieldDefinitionNamesRule.mjs +6 -2
- package/validation/rules/UniqueFragmentNamesRule.js +3 -1
- package/validation/rules/UniqueFragmentNamesRule.mjs +3 -1
- package/validation/rules/UniqueInputFieldNamesRule.js +3 -1
- package/validation/rules/UniqueInputFieldNamesRule.mjs +3 -1
- package/validation/rules/UniqueOperationNamesRule.js +6 -1
- package/validation/rules/UniqueOperationNamesRule.mjs +6 -1
- package/validation/rules/UniqueOperationTypesRule.js +6 -2
- package/validation/rules/UniqueOperationTypesRule.mjs +6 -2
- package/validation/rules/UniqueTypeNamesRule.js +6 -2
- package/validation/rules/UniqueTypeNamesRule.mjs +6 -5
- package/validation/rules/UniqueVariableNamesRule.js +3 -1
- package/validation/rules/UniqueVariableNamesRule.mjs +3 -1
- package/validation/rules/ValuesOfCorrectTypeRule.js +19 -10
- package/validation/rules/ValuesOfCorrectTypeRule.mjs +19 -10
- package/validation/rules/VariablesAreInputTypesRule.js +3 -1
- package/validation/rules/VariablesAreInputTypesRule.mjs +3 -1
- package/validation/rules/VariablesInAllowedPositionRule.js +3 -1
- package/validation/rules/VariablesInAllowedPositionRule.mjs +3 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.js +15 -5
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs +15 -5
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +3 -1
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs +3 -1
- package/version.js +2 -2
- package/version.mjs +2 -2
package/type/definition.d.ts
CHANGED
|
@@ -302,10 +302,9 @@ export interface GraphQLScalarTypeExtensions {
|
|
|
302
302
|
* Scalars (or Enums) and are defined with a name and a series of functions
|
|
303
303
|
* used to parse input from ast or variables and to ensure validity.
|
|
304
304
|
*
|
|
305
|
-
* If a type's serialize function does not return a value
|
|
306
|
-
* `undefined`) then an error will be raised and a `null`
|
|
307
|
-
* in the response.
|
|
308
|
-
* be included in the response.
|
|
305
|
+
* If a type's serialize function returns `null` or does not return a value
|
|
306
|
+
* (i.e. it returns `undefined`) then an error will be raised and a `null`
|
|
307
|
+
* value will be returned in the response. It is always better to validate
|
|
309
308
|
*
|
|
310
309
|
* Example:
|
|
311
310
|
*
|
|
@@ -313,9 +312,16 @@ export interface GraphQLScalarTypeExtensions {
|
|
|
313
312
|
* const OddType = new GraphQLScalarType({
|
|
314
313
|
* name: 'Odd',
|
|
315
314
|
* serialize(value) {
|
|
316
|
-
* if (value
|
|
317
|
-
*
|
|
315
|
+
* if (!Number.isFinite(value)) {
|
|
316
|
+
* throw new Error(
|
|
317
|
+
* `Scalar "Odd" cannot represent "${value}" since it is not a finite number.`,
|
|
318
|
+
* );
|
|
318
319
|
* }
|
|
320
|
+
*
|
|
321
|
+
* if (value % 2 === 0) {
|
|
322
|
+
* throw new Error(`Scalar "Odd" cannot represent "${value}" since it is even.`);
|
|
323
|
+
* }
|
|
324
|
+
* return value;
|
|
319
325
|
* }
|
|
320
326
|
* });
|
|
321
327
|
* ```
|
package/type/definition.js
CHANGED
|
@@ -520,10 +520,9 @@ function resolveObjMapThunk(thunk) {
|
|
|
520
520
|
* Scalars (or Enums) and are defined with a name and a series of functions
|
|
521
521
|
* used to parse input from ast or variables and to ensure validity.
|
|
522
522
|
*
|
|
523
|
-
* If a type's serialize function does not return a value
|
|
524
|
-
* `undefined`) then an error will be raised and a `null`
|
|
525
|
-
* in the response.
|
|
526
|
-
* be included in the response.
|
|
523
|
+
* If a type's serialize function returns `null` or does not return a value
|
|
524
|
+
* (i.e. it returns `undefined`) then an error will be raised and a `null`
|
|
525
|
+
* value will be returned in the response. It is always better to validate
|
|
527
526
|
*
|
|
528
527
|
* Example:
|
|
529
528
|
*
|
|
@@ -531,9 +530,16 @@ function resolveObjMapThunk(thunk) {
|
|
|
531
530
|
* const OddType = new GraphQLScalarType({
|
|
532
531
|
* name: 'Odd',
|
|
533
532
|
* serialize(value) {
|
|
534
|
-
* if (value
|
|
535
|
-
*
|
|
533
|
+
* if (!Number.isFinite(value)) {
|
|
534
|
+
* throw new Error(
|
|
535
|
+
* `Scalar "Odd" cannot represent "${value}" since it is not a finite number.`,
|
|
536
|
+
* );
|
|
536
537
|
* }
|
|
538
|
+
*
|
|
539
|
+
* if (value % 2 === 0) {
|
|
540
|
+
* throw new Error(`Scalar "Odd" cannot represent "${value}" since it is even.`);
|
|
541
|
+
* }
|
|
542
|
+
* return value;
|
|
537
543
|
* }
|
|
538
544
|
* });
|
|
539
545
|
* ```
|
|
@@ -1134,7 +1140,9 @@ class GraphQLEnumType {
|
|
|
1134
1140
|
throw new _GraphQLError.GraphQLError(
|
|
1135
1141
|
`Enum "${this.name}" cannot represent non-enum value: ${valueStr}.` +
|
|
1136
1142
|
didYouMeanEnumValue(this, valueStr),
|
|
1137
|
-
|
|
1143
|
+
{
|
|
1144
|
+
nodes: valueNode,
|
|
1145
|
+
},
|
|
1138
1146
|
);
|
|
1139
1147
|
}
|
|
1140
1148
|
|
|
@@ -1145,7 +1153,9 @@ class GraphQLEnumType {
|
|
|
1145
1153
|
throw new _GraphQLError.GraphQLError(
|
|
1146
1154
|
`Value "${valueStr}" does not exist in "${this.name}" enum.` +
|
|
1147
1155
|
didYouMeanEnumValue(this, valueStr),
|
|
1148
|
-
|
|
1156
|
+
{
|
|
1157
|
+
nodes: valueNode,
|
|
1158
|
+
},
|
|
1149
1159
|
);
|
|
1150
1160
|
}
|
|
1151
1161
|
|
package/type/definition.mjs
CHANGED
|
@@ -381,10 +381,9 @@ export function resolveObjMapThunk(thunk) {
|
|
|
381
381
|
* Scalars (or Enums) and are defined with a name and a series of functions
|
|
382
382
|
* used to parse input from ast or variables and to ensure validity.
|
|
383
383
|
*
|
|
384
|
-
* If a type's serialize function does not return a value
|
|
385
|
-
* `undefined`) then an error will be raised and a `null`
|
|
386
|
-
* in the response.
|
|
387
|
-
* be included in the response.
|
|
384
|
+
* If a type's serialize function returns `null` or does not return a value
|
|
385
|
+
* (i.e. it returns `undefined`) then an error will be raised and a `null`
|
|
386
|
+
* value will be returned in the response. It is always better to validate
|
|
388
387
|
*
|
|
389
388
|
* Example:
|
|
390
389
|
*
|
|
@@ -392,9 +391,16 @@ export function resolveObjMapThunk(thunk) {
|
|
|
392
391
|
* const OddType = new GraphQLScalarType({
|
|
393
392
|
* name: 'Odd',
|
|
394
393
|
* serialize(value) {
|
|
395
|
-
* if (value
|
|
396
|
-
*
|
|
394
|
+
* if (!Number.isFinite(value)) {
|
|
395
|
+
* throw new Error(
|
|
396
|
+
* `Scalar "Odd" cannot represent "${value}" since it is not a finite number.`,
|
|
397
|
+
* );
|
|
397
398
|
* }
|
|
399
|
+
*
|
|
400
|
+
* if (value % 2 === 0) {
|
|
401
|
+
* throw new Error(`Scalar "Odd" cannot represent "${value}" since it is even.`);
|
|
402
|
+
* }
|
|
403
|
+
* return value;
|
|
398
404
|
* }
|
|
399
405
|
* });
|
|
400
406
|
* ```
|
|
@@ -981,7 +987,9 @@ export class GraphQLEnumType {
|
|
|
981
987
|
throw new GraphQLError(
|
|
982
988
|
`Enum "${this.name}" cannot represent non-enum value: ${valueStr}.` +
|
|
983
989
|
didYouMeanEnumValue(this, valueStr),
|
|
984
|
-
|
|
990
|
+
{
|
|
991
|
+
nodes: valueNode,
|
|
992
|
+
},
|
|
985
993
|
);
|
|
986
994
|
}
|
|
987
995
|
|
|
@@ -992,7 +1000,9 @@ export class GraphQLEnumType {
|
|
|
992
1000
|
throw new GraphQLError(
|
|
993
1001
|
`Value "${valueStr}" does not exist in "${this.name}" enum.` +
|
|
994
1002
|
didYouMeanEnumValue(this, valueStr),
|
|
995
|
-
|
|
1003
|
+
{
|
|
1004
|
+
nodes: valueNode,
|
|
1005
|
+
},
|
|
996
1006
|
);
|
|
997
1007
|
}
|
|
998
1008
|
|
package/type/scalars.js
CHANGED
|
@@ -99,7 +99,9 @@ const GraphQLInt = new _definition.GraphQLScalarType({
|
|
|
99
99
|
`Int cannot represent non-integer value: ${(0, _printer.print)(
|
|
100
100
|
valueNode,
|
|
101
101
|
)}`,
|
|
102
|
-
|
|
102
|
+
{
|
|
103
|
+
nodes: valueNode,
|
|
104
|
+
},
|
|
103
105
|
);
|
|
104
106
|
}
|
|
105
107
|
|
|
@@ -108,7 +110,9 @@ const GraphQLInt = new _definition.GraphQLScalarType({
|
|
|
108
110
|
if (num > GRAPHQL_MAX_INT || num < GRAPHQL_MIN_INT) {
|
|
109
111
|
throw new _GraphQLError.GraphQLError(
|
|
110
112
|
`Int cannot represent non 32-bit signed integer value: ${valueNode.value}`,
|
|
111
|
-
|
|
113
|
+
{
|
|
114
|
+
nodes: valueNode,
|
|
115
|
+
},
|
|
112
116
|
);
|
|
113
117
|
}
|
|
114
118
|
|
|
@@ -218,7 +222,9 @@ const GraphQLString = new _definition.GraphQLScalarType({
|
|
|
218
222
|
`String cannot represent a non string value: ${(0, _printer.print)(
|
|
219
223
|
valueNode,
|
|
220
224
|
)}`,
|
|
221
|
-
|
|
225
|
+
{
|
|
226
|
+
nodes: valueNode,
|
|
227
|
+
},
|
|
222
228
|
);
|
|
223
229
|
}
|
|
224
230
|
|
|
@@ -266,7 +272,9 @@ const GraphQLBoolean = new _definition.GraphQLScalarType({
|
|
|
266
272
|
`Boolean cannot represent a non boolean value: ${(0, _printer.print)(
|
|
267
273
|
valueNode,
|
|
268
274
|
)}`,
|
|
269
|
-
|
|
275
|
+
{
|
|
276
|
+
nodes: valueNode,
|
|
277
|
+
},
|
|
270
278
|
);
|
|
271
279
|
}
|
|
272
280
|
|
|
@@ -317,7 +325,9 @@ const GraphQLID = new _definition.GraphQLScalarType({
|
|
|
317
325
|
throw new _GraphQLError.GraphQLError(
|
|
318
326
|
'ID cannot represent a non-string and non-integer value: ' +
|
|
319
327
|
(0, _printer.print)(valueNode),
|
|
320
|
-
|
|
328
|
+
{
|
|
329
|
+
nodes: valueNode,
|
|
330
|
+
},
|
|
321
331
|
);
|
|
322
332
|
}
|
|
323
333
|
|
package/type/scalars.mjs
CHANGED
|
@@ -70,7 +70,9 @@ export const GraphQLInt = new GraphQLScalarType({
|
|
|
70
70
|
if (valueNode.kind !== Kind.INT) {
|
|
71
71
|
throw new GraphQLError(
|
|
72
72
|
`Int cannot represent non-integer value: ${print(valueNode)}`,
|
|
73
|
-
|
|
73
|
+
{
|
|
74
|
+
nodes: valueNode,
|
|
75
|
+
},
|
|
74
76
|
);
|
|
75
77
|
}
|
|
76
78
|
|
|
@@ -79,7 +81,9 @@ export const GraphQLInt = new GraphQLScalarType({
|
|
|
79
81
|
if (num > GRAPHQL_MAX_INT || num < GRAPHQL_MIN_INT) {
|
|
80
82
|
throw new GraphQLError(
|
|
81
83
|
`Int cannot represent non 32-bit signed integer value: ${valueNode.value}`,
|
|
82
|
-
|
|
84
|
+
{
|
|
85
|
+
nodes: valueNode,
|
|
86
|
+
},
|
|
83
87
|
);
|
|
84
88
|
}
|
|
85
89
|
|
|
@@ -174,7 +178,9 @@ export const GraphQLString = new GraphQLScalarType({
|
|
|
174
178
|
if (valueNode.kind !== Kind.STRING) {
|
|
175
179
|
throw new GraphQLError(
|
|
176
180
|
`String cannot represent a non string value: ${print(valueNode)}`,
|
|
177
|
-
|
|
181
|
+
{
|
|
182
|
+
nodes: valueNode,
|
|
183
|
+
},
|
|
178
184
|
);
|
|
179
185
|
}
|
|
180
186
|
|
|
@@ -215,7 +221,9 @@ export const GraphQLBoolean = new GraphQLScalarType({
|
|
|
215
221
|
if (valueNode.kind !== Kind.BOOLEAN) {
|
|
216
222
|
throw new GraphQLError(
|
|
217
223
|
`Boolean cannot represent a non boolean value: ${print(valueNode)}`,
|
|
218
|
-
|
|
224
|
+
{
|
|
225
|
+
nodes: valueNode,
|
|
226
|
+
},
|
|
219
227
|
);
|
|
220
228
|
}
|
|
221
229
|
|
|
@@ -260,7 +268,9 @@ export const GraphQLID = new GraphQLScalarType({
|
|
|
260
268
|
throw new GraphQLError(
|
|
261
269
|
'ID cannot represent a non-string and non-integer value: ' +
|
|
262
270
|
print(valueNode),
|
|
263
|
-
|
|
271
|
+
{
|
|
272
|
+
nodes: valueNode,
|
|
273
|
+
},
|
|
264
274
|
);
|
|
265
275
|
}
|
|
266
276
|
|
package/type/validate.js
CHANGED
|
@@ -69,7 +69,11 @@ class SchemaValidationContext {
|
|
|
69
69
|
reportError(message, nodes) {
|
|
70
70
|
const _nodes = Array.isArray(nodes) ? nodes.filter(Boolean) : nodes;
|
|
71
71
|
|
|
72
|
-
this._errors.push(
|
|
72
|
+
this._errors.push(
|
|
73
|
+
new _GraphQLError.GraphQLError(message, {
|
|
74
|
+
nodes: _nodes,
|
|
75
|
+
}),
|
|
76
|
+
);
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
getErrors() {
|
package/type/validate.mjs
CHANGED
|
@@ -66,7 +66,11 @@ class SchemaValidationContext {
|
|
|
66
66
|
reportError(message, nodes) {
|
|
67
67
|
const _nodes = Array.isArray(nodes) ? nodes.filter(Boolean) : nodes;
|
|
68
68
|
|
|
69
|
-
this._errors.push(
|
|
69
|
+
this._errors.push(
|
|
70
|
+
new GraphQLError(message, {
|
|
71
|
+
nodes: _nodes,
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
getErrors() {
|
|
@@ -158,11 +158,9 @@ function coerceInputValueImpl(inputValue, type, onError, path) {
|
|
|
158
158
|
inputValue,
|
|
159
159
|
new _GraphQLError.GraphQLError(
|
|
160
160
|
`Expected type "${type.name}". ` + error.message,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
undefined,
|
|
165
|
-
error,
|
|
161
|
+
{
|
|
162
|
+
originalError: error,
|
|
163
|
+
},
|
|
166
164
|
),
|
|
167
165
|
);
|
|
168
166
|
}
|
|
@@ -141,14 +141,9 @@ function coerceInputValueImpl(inputValue, type, onError, path) {
|
|
|
141
141
|
onError(
|
|
142
142
|
pathToArray(path),
|
|
143
143
|
inputValue,
|
|
144
|
-
new GraphQLError(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
undefined,
|
|
148
|
-
undefined,
|
|
149
|
-
undefined,
|
|
150
|
-
error,
|
|
151
|
-
),
|
|
144
|
+
new GraphQLError(`Expected type "${type.name}". ` + error.message, {
|
|
145
|
+
originalError: error,
|
|
146
|
+
}),
|
|
152
147
|
);
|
|
153
148
|
}
|
|
154
149
|
|
|
@@ -19,7 +19,9 @@ function getOperationRootType(schema, operation) {
|
|
|
19
19
|
if (!queryType) {
|
|
20
20
|
throw new _GraphQLError.GraphQLError(
|
|
21
21
|
'Schema does not define the required query root type.',
|
|
22
|
-
|
|
22
|
+
{
|
|
23
|
+
nodes: operation,
|
|
24
|
+
},
|
|
23
25
|
);
|
|
24
26
|
}
|
|
25
27
|
|
|
@@ -32,7 +34,9 @@ function getOperationRootType(schema, operation) {
|
|
|
32
34
|
if (!mutationType) {
|
|
33
35
|
throw new _GraphQLError.GraphQLError(
|
|
34
36
|
'Schema is not configured for mutations.',
|
|
35
|
-
|
|
37
|
+
{
|
|
38
|
+
nodes: operation,
|
|
39
|
+
},
|
|
36
40
|
);
|
|
37
41
|
}
|
|
38
42
|
|
|
@@ -45,7 +49,9 @@ function getOperationRootType(schema, operation) {
|
|
|
45
49
|
if (!subscriptionType) {
|
|
46
50
|
throw new _GraphQLError.GraphQLError(
|
|
47
51
|
'Schema is not configured for subscriptions.',
|
|
48
|
-
|
|
52
|
+
{
|
|
53
|
+
nodes: operation,
|
|
54
|
+
},
|
|
49
55
|
);
|
|
50
56
|
}
|
|
51
57
|
|
|
@@ -54,6 +60,8 @@ function getOperationRootType(schema, operation) {
|
|
|
54
60
|
|
|
55
61
|
throw new _GraphQLError.GraphQLError(
|
|
56
62
|
'Can only have query, mutation and subscription operations.',
|
|
57
|
-
|
|
63
|
+
{
|
|
64
|
+
nodes: operation,
|
|
65
|
+
},
|
|
58
66
|
);
|
|
59
67
|
}
|
|
@@ -12,7 +12,9 @@ export function getOperationRootType(schema, operation) {
|
|
|
12
12
|
if (!queryType) {
|
|
13
13
|
throw new GraphQLError(
|
|
14
14
|
'Schema does not define the required query root type.',
|
|
15
|
-
|
|
15
|
+
{
|
|
16
|
+
nodes: operation,
|
|
17
|
+
},
|
|
16
18
|
);
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -23,10 +25,9 @@ export function getOperationRootType(schema, operation) {
|
|
|
23
25
|
const mutationType = schema.getMutationType();
|
|
24
26
|
|
|
25
27
|
if (!mutationType) {
|
|
26
|
-
throw new GraphQLError(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
28
|
+
throw new GraphQLError('Schema is not configured for mutations.', {
|
|
29
|
+
nodes: operation,
|
|
30
|
+
});
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
return mutationType;
|
|
@@ -36,10 +37,9 @@ export function getOperationRootType(schema, operation) {
|
|
|
36
37
|
const subscriptionType = schema.getSubscriptionType();
|
|
37
38
|
|
|
38
39
|
if (!subscriptionType) {
|
|
39
|
-
throw new GraphQLError(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
);
|
|
40
|
+
throw new GraphQLError('Schema is not configured for subscriptions.', {
|
|
41
|
+
nodes: operation,
|
|
42
|
+
});
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
return subscriptionType;
|
|
@@ -47,6 +47,8 @@ export function getOperationRootType(schema, operation) {
|
|
|
47
47
|
|
|
48
48
|
throw new GraphQLError(
|
|
49
49
|
'Can only have query, mutation and subscription operations.',
|
|
50
|
-
|
|
50
|
+
{
|
|
51
|
+
nodes: operation,
|
|
52
|
+
},
|
|
51
53
|
);
|
|
52
54
|
}
|
|
@@ -21,10 +21,9 @@ export function ExecutableDefinitionsRule(context) {
|
|
|
21
21
|
? 'schema'
|
|
22
22
|
: '"' + definition.name.value + '"';
|
|
23
23
|
context.reportError(
|
|
24
|
-
new GraphQLError(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
),
|
|
24
|
+
new GraphQLError(`The ${defName} definition is not executable.`, {
|
|
25
|
+
nodes: definition,
|
|
26
|
+
}),
|
|
28
27
|
);
|
|
29
28
|
}
|
|
30
29
|
}
|
|
@@ -38,7 +38,9 @@ function FragmentsOnCompositeTypesRule(context) {
|
|
|
38
38
|
context.reportError(
|
|
39
39
|
new _GraphQLError.GraphQLError(
|
|
40
40
|
`Fragment cannot condition on non composite type "${typeStr}".`,
|
|
41
|
-
|
|
41
|
+
{
|
|
42
|
+
nodes: typeCondition,
|
|
43
|
+
},
|
|
42
44
|
),
|
|
43
45
|
);
|
|
44
46
|
}
|
|
@@ -56,7 +58,9 @@ function FragmentsOnCompositeTypesRule(context) {
|
|
|
56
58
|
context.reportError(
|
|
57
59
|
new _GraphQLError.GraphQLError(
|
|
58
60
|
`Fragment "${node.name.value}" cannot condition on non composite type "${typeStr}".`,
|
|
59
|
-
|
|
61
|
+
{
|
|
62
|
+
nodes: node.typeCondition,
|
|
63
|
+
},
|
|
60
64
|
),
|
|
61
65
|
);
|
|
62
66
|
}
|
|
@@ -25,7 +25,9 @@ export function FragmentsOnCompositeTypesRule(context) {
|
|
|
25
25
|
context.reportError(
|
|
26
26
|
new GraphQLError(
|
|
27
27
|
`Fragment cannot condition on non composite type "${typeStr}".`,
|
|
28
|
-
|
|
28
|
+
{
|
|
29
|
+
nodes: typeCondition,
|
|
30
|
+
},
|
|
29
31
|
),
|
|
30
32
|
);
|
|
31
33
|
}
|
|
@@ -40,7 +42,9 @@ export function FragmentsOnCompositeTypesRule(context) {
|
|
|
40
42
|
context.reportError(
|
|
41
43
|
new GraphQLError(
|
|
42
44
|
`Fragment "${node.name.value}" cannot condition on non composite type "${typeStr}".`,
|
|
43
|
-
|
|
45
|
+
{
|
|
46
|
+
nodes: node.typeCondition,
|
|
47
|
+
},
|
|
44
48
|
),
|
|
45
49
|
);
|
|
46
50
|
}
|
|
@@ -46,7 +46,9 @@ function KnownArgumentNamesRule(context) {
|
|
|
46
46
|
new _GraphQLError.GraphQLError(
|
|
47
47
|
`Unknown argument "${argName}" on field "${parentType.name}.${fieldDef.name}".` +
|
|
48
48
|
(0, _didYouMean.didYouMean)(suggestions),
|
|
49
|
-
|
|
49
|
+
{
|
|
50
|
+
nodes: argNode,
|
|
51
|
+
},
|
|
50
52
|
),
|
|
51
53
|
);
|
|
52
54
|
}
|
|
@@ -103,7 +105,9 @@ function KnownArgumentNamesOnDirectivesRule(context) {
|
|
|
103
105
|
new _GraphQLError.GraphQLError(
|
|
104
106
|
`Unknown argument "${argName}" on directive "@${directiveName}".` +
|
|
105
107
|
(0, _didYouMean.didYouMean)(suggestions),
|
|
106
|
-
|
|
108
|
+
{
|
|
109
|
+
nodes: argNode,
|
|
110
|
+
},
|
|
107
111
|
),
|
|
108
112
|
);
|
|
109
113
|
}
|
|
@@ -31,7 +31,9 @@ export function KnownArgumentNamesRule(context) {
|
|
|
31
31
|
new GraphQLError(
|
|
32
32
|
`Unknown argument "${argName}" on field "${parentType.name}.${fieldDef.name}".` +
|
|
33
33
|
didYouMean(suggestions),
|
|
34
|
-
|
|
34
|
+
{
|
|
35
|
+
nodes: argNode,
|
|
36
|
+
},
|
|
35
37
|
),
|
|
36
38
|
);
|
|
37
39
|
}
|
|
@@ -85,7 +87,9 @@ export function KnownArgumentNamesOnDirectivesRule(context) {
|
|
|
85
87
|
new GraphQLError(
|
|
86
88
|
`Unknown argument "${argName}" on directive "@${directiveName}".` +
|
|
87
89
|
didYouMean(suggestions),
|
|
88
|
-
|
|
90
|
+
{
|
|
91
|
+
nodes: argNode,
|
|
92
|
+
},
|
|
89
93
|
),
|
|
90
94
|
);
|
|
91
95
|
}
|
|
@@ -53,7 +53,9 @@ function KnownDirectivesRule(context) {
|
|
|
53
53
|
|
|
54
54
|
if (!locations) {
|
|
55
55
|
context.reportError(
|
|
56
|
-
new _GraphQLError.GraphQLError(`Unknown directive "@${name}".`,
|
|
56
|
+
new _GraphQLError.GraphQLError(`Unknown directive "@${name}".`, {
|
|
57
|
+
nodes: node,
|
|
58
|
+
}),
|
|
57
59
|
);
|
|
58
60
|
return;
|
|
59
61
|
}
|
|
@@ -64,7 +66,9 @@ function KnownDirectivesRule(context) {
|
|
|
64
66
|
context.reportError(
|
|
65
67
|
new _GraphQLError.GraphQLError(
|
|
66
68
|
`Directive "@${name}" may not be used on ${candidateLocation}.`,
|
|
67
|
-
|
|
69
|
+
{
|
|
70
|
+
nodes: node,
|
|
71
|
+
},
|
|
68
72
|
),
|
|
69
73
|
);
|
|
70
74
|
}
|
|
@@ -40,7 +40,9 @@ export function KnownDirectivesRule(context) {
|
|
|
40
40
|
|
|
41
41
|
if (!locations) {
|
|
42
42
|
context.reportError(
|
|
43
|
-
new GraphQLError(`Unknown directive "@${name}".`,
|
|
43
|
+
new GraphQLError(`Unknown directive "@${name}".`, {
|
|
44
|
+
nodes: node,
|
|
45
|
+
}),
|
|
44
46
|
);
|
|
45
47
|
return;
|
|
46
48
|
}
|
|
@@ -51,7 +53,9 @@ export function KnownDirectivesRule(context) {
|
|
|
51
53
|
context.reportError(
|
|
52
54
|
new GraphQLError(
|
|
53
55
|
`Directive "@${name}" may not be used on ${candidateLocation}.`,
|
|
54
|
-
|
|
56
|
+
{
|
|
57
|
+
nodes: node,
|
|
58
|
+
},
|
|
55
59
|
),
|
|
56
60
|
);
|
|
57
61
|
}
|
|
@@ -16,7 +16,9 @@ export function KnownFragmentNamesRule(context) {
|
|
|
16
16
|
|
|
17
17
|
if (!fragment) {
|
|
18
18
|
context.reportError(
|
|
19
|
-
new GraphQLError(`Unknown fragment "${fragmentName}".`,
|
|
19
|
+
new GraphQLError(`Unknown fragment "${fragmentName}".`, {
|
|
20
|
+
nodes: node.name,
|
|
21
|
+
}),
|
|
20
22
|
);
|
|
21
23
|
}
|
|
22
24
|
},
|