@graphitation/supermassive 2.2.2 → 2.2.3
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/.eslintcache +1 -1
- package/lib/ast/TypedAST.js +1 -0
- package/lib/ast/addTypesToRequestDocument.js +48 -42
- package/lib/ast/addTypesToRequestDocument.mjs +47 -42
- package/lib/benchmarks/index.js +15 -4
- package/lib/benchmarks/index.mjs +6 -3
- package/lib/benchmarks/nice-benchmark.js +1 -0
- package/lib/benchmarks/swapi-schema/index.js +14 -4
- package/lib/benchmarks/swapi-schema/index.mjs +5 -3
- package/lib/benchmarks/swapi-schema/models.js +9 -1
- package/lib/benchmarks/swapi-schema/resolvers.js +22 -7
- package/lib/benchmarks/swapi-schema/resolvers.mjs +21 -7
- package/lib/collectFields.js +41 -11
- package/lib/collectFields.mjs +40 -11
- package/lib/compiledQuery.js +1 -0
- package/lib/definition.js +13 -8
- package/lib/definition.mjs +12 -8
- package/lib/directives.js +48 -33
- package/lib/directives.mjs +47 -33
- package/lib/executeWithSchema.js +1 -0
- package/lib/executeWithoutSchema.js +231 -49
- package/lib/executeWithoutSchema.mjs +224 -46
- package/lib/extractImplicitTypesRuntime.js +4 -1
- package/lib/extractImplicitTypesRuntime.mjs +3 -1
- package/lib/index.js +1 -0
- package/lib/jsutils/Maybe.js +1 -0
- package/lib/jsutils/ObjMap.js +1 -0
- package/lib/jsutils/Path.js +1 -0
- package/lib/jsutils/PromiseOrValue.js +1 -0
- package/lib/jsutils/devAssert.js +1 -0
- package/lib/jsutils/didYouMean.js +1 -0
- package/lib/jsutils/identityFunc.js +1 -0
- package/lib/jsutils/inspect.js +4 -1
- package/lib/jsutils/inspect.mjs +3 -1
- package/lib/jsutils/instanceOf.js +18 -6
- package/lib/jsutils/instanceOf.mjs +17 -6
- package/lib/jsutils/invariant.js +4 -1
- package/lib/jsutils/invariant.mjs +3 -1
- package/lib/jsutils/isAsyncIterable.js +1 -0
- package/lib/jsutils/isIterableObject.js +1 -0
- package/lib/jsutils/isObjectLike.js +1 -0
- package/lib/jsutils/isPromise.js +1 -0
- package/lib/jsutils/keyMap.js +1 -0
- package/lib/jsutils/keyValMap.js +1 -0
- package/lib/jsutils/mapValue.js +1 -0
- package/lib/jsutils/memoize3.js +1 -0
- package/lib/jsutils/naturalCompare.js +1 -0
- package/lib/jsutils/printPathArray.js +4 -1
- package/lib/jsutils/printPathArray.mjs +3 -1
- package/lib/jsutils/promiseForObject.js +1 -0
- package/lib/jsutils/promiseReduce.js +1 -0
- package/lib/jsutils/suggestionList.js +9 -1
- package/lib/jsutils/suggestionList.mjs +8 -1
- package/lib/jsutils/toObjMap.js +1 -0
- package/lib/subscribeWithSchema.js +1 -0
- package/lib/subscribeWithoutSchema.js +45 -6
- package/lib/subscribeWithoutSchema.mjs +44 -6
- package/lib/transforms/annotateDocumentGraphQLTransform.js +1 -0
- package/lib/types.js +1 -0
- package/lib/utilities/blankGraphQLTag.js +1 -0
- package/lib/utilities/mapAsyncIterator.js +1 -0
- package/lib/utilities/mergeResolvers.js +1 -0
- package/lib/utilities/typeNameFromAST.js +1 -0
- package/lib/values.js +82 -21
- package/lib/values.mjs +81 -21
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -55,7 +56,16 @@ function executeWithoutSchema(args) {
|
|
|
55
56
|
} = args;
|
|
56
57
|
const combinedResolvers = (0, import_mergeResolvers.mergeResolvers)(resolvers, schemaResolvers);
|
|
57
58
|
assertValidExecutionArguments(document, variableValues);
|
|
58
|
-
const exeContext = buildExecutionContext(
|
|
59
|
+
const exeContext = buildExecutionContext(
|
|
60
|
+
combinedResolvers,
|
|
61
|
+
document,
|
|
62
|
+
rootValue,
|
|
63
|
+
contextValue,
|
|
64
|
+
variableValues,
|
|
65
|
+
operationName,
|
|
66
|
+
fieldResolver,
|
|
67
|
+
typeResolver
|
|
68
|
+
);
|
|
59
69
|
if (!("resolvers" in exeContext)) {
|
|
60
70
|
return { errors: exeContext };
|
|
61
71
|
} else {
|
|
@@ -65,13 +75,18 @@ function executeWithoutSchema(args) {
|
|
|
65
75
|
}
|
|
66
76
|
function buildResponse(exeContext, data) {
|
|
67
77
|
if ((0, import_isPromise.isPromise)(data)) {
|
|
68
|
-
return data.then(
|
|
78
|
+
return data.then(
|
|
79
|
+
(resolved) => buildResponse(exeContext, resolved)
|
|
80
|
+
);
|
|
69
81
|
}
|
|
70
82
|
return exeContext.errors.length === 0 ? { data } : { errors: exeContext.errors, data };
|
|
71
83
|
}
|
|
72
84
|
function assertValidExecutionArguments(document, rawVariableValues) {
|
|
73
85
|
(0, import_devAssert.devAssert)(document, "Must provide document.");
|
|
74
|
-
(0, import_devAssert.devAssert)(
|
|
86
|
+
(0, import_devAssert.devAssert)(
|
|
87
|
+
rawVariableValues == null || (0, import_isObjectLike.isObjectLike)(rawVariableValues),
|
|
88
|
+
"Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided."
|
|
89
|
+
);
|
|
75
90
|
}
|
|
76
91
|
function buildExecutionContext(resolvers, document, rootValue, contextValue, rawVariableValues, operationName, fieldResolver, typeResolver) {
|
|
77
92
|
var _a, _b;
|
|
@@ -83,7 +98,9 @@ function buildExecutionContext(resolvers, document, rootValue, contextValue, raw
|
|
|
83
98
|
if (operationName == null) {
|
|
84
99
|
if (operation !== void 0) {
|
|
85
100
|
return [
|
|
86
|
-
new import_graphql.GraphQLError(
|
|
101
|
+
new import_graphql.GraphQLError(
|
|
102
|
+
"Must provide operation name if query contains multiple operations."
|
|
103
|
+
)
|
|
87
104
|
];
|
|
88
105
|
}
|
|
89
106
|
operation = definition;
|
|
@@ -103,7 +120,12 @@ function buildExecutionContext(resolvers, document, rootValue, contextValue, raw
|
|
|
103
120
|
return [new import_graphql.GraphQLError("Must provide an operation.")];
|
|
104
121
|
}
|
|
105
122
|
const variableDefinitions = (_b = operation.variableDefinitions) != null ? _b : [];
|
|
106
|
-
const coercedVariableValues = (0, import_values.getVariableValues)(
|
|
123
|
+
const coercedVariableValues = (0, import_values.getVariableValues)(
|
|
124
|
+
resolvers,
|
|
125
|
+
variableDefinitions,
|
|
126
|
+
rawVariableValues != null ? rawVariableValues : {},
|
|
127
|
+
{ maxErrors: 50 }
|
|
128
|
+
);
|
|
107
129
|
if (coercedVariableValues.errors) {
|
|
108
130
|
return coercedVariableValues.errors;
|
|
109
131
|
}
|
|
@@ -121,7 +143,15 @@ function buildExecutionContext(resolvers, document, rootValue, contextValue, raw
|
|
|
121
143
|
}
|
|
122
144
|
function executeOperation(exeContext, operation, rootValue) {
|
|
123
145
|
const typeName = getOperationRootTypeName(operation);
|
|
124
|
-
const fields = (0, import_collectFields.collectFields)(
|
|
146
|
+
const fields = (0, import_collectFields.collectFields)(
|
|
147
|
+
exeContext.resolvers,
|
|
148
|
+
exeContext.fragments,
|
|
149
|
+
exeContext.variableValues,
|
|
150
|
+
typeName,
|
|
151
|
+
operation.selectionSet,
|
|
152
|
+
/* @__PURE__ */ new Map(),
|
|
153
|
+
/* @__PURE__ */ new Set()
|
|
154
|
+
);
|
|
125
155
|
const path = void 0;
|
|
126
156
|
try {
|
|
127
157
|
const result = operation.operation === "mutation" ? executeFieldsSerially(exeContext, typeName, rootValue, path, fields) : executeFields(exeContext, typeName, rootValue, path, fields);
|
|
@@ -138,28 +168,44 @@ function executeOperation(exeContext, operation, rootValue) {
|
|
|
138
168
|
}
|
|
139
169
|
}
|
|
140
170
|
function executeFieldsSerially(exeContext, parentTypeName, sourceValue, path, fields) {
|
|
141
|
-
return (0, import_promiseReduce.promiseReduce)(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
171
|
+
return (0, import_promiseReduce.promiseReduce)(
|
|
172
|
+
fields.entries(),
|
|
173
|
+
(results, [responseName, fieldNodes]) => {
|
|
174
|
+
const fieldPath = (0, import_Path.addPath)(path, responseName, parentTypeName);
|
|
175
|
+
const result = executeField(
|
|
176
|
+
exeContext,
|
|
177
|
+
parentTypeName,
|
|
178
|
+
sourceValue,
|
|
179
|
+
fieldNodes,
|
|
180
|
+
fieldPath
|
|
181
|
+
);
|
|
182
|
+
if (result === void 0) {
|
|
150
183
|
return results;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
184
|
+
}
|
|
185
|
+
if ((0, import_isPromise.isPromise)(result)) {
|
|
186
|
+
return result.then((resolvedResult) => {
|
|
187
|
+
results[responseName] = resolvedResult;
|
|
188
|
+
return results;
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
results[responseName] = result;
|
|
192
|
+
return results;
|
|
193
|
+
},
|
|
194
|
+
/* @__PURE__ */ Object.create(null)
|
|
195
|
+
);
|
|
156
196
|
}
|
|
157
197
|
function executeFields(exeContext, parentTypeName, sourceValue, path, fields) {
|
|
158
198
|
const results = /* @__PURE__ */ Object.create(null);
|
|
159
199
|
let containsPromise = false;
|
|
160
200
|
for (const [responseName, fieldNodes] of fields.entries()) {
|
|
161
201
|
const fieldPath = (0, import_Path.addPath)(path, responseName, parentTypeName);
|
|
162
|
-
const result = executeField(
|
|
202
|
+
const result = executeField(
|
|
203
|
+
exeContext,
|
|
204
|
+
parentTypeName,
|
|
205
|
+
sourceValue,
|
|
206
|
+
fieldNodes,
|
|
207
|
+
fieldPath
|
|
208
|
+
);
|
|
163
209
|
if (result !== void 0) {
|
|
164
210
|
results[responseName] = result;
|
|
165
211
|
if ((0, import_isPromise.isPromise)(result)) {
|
|
@@ -199,26 +245,62 @@ function executeField(exeContext, parentTypeName, source, fieldNodes, path) {
|
|
|
199
245
|
if (!resolveFn) {
|
|
200
246
|
resolveFn = exeContext.fieldResolver;
|
|
201
247
|
}
|
|
202
|
-
const info = buildResolveInfo(
|
|
248
|
+
const info = buildResolveInfo(
|
|
249
|
+
exeContext,
|
|
250
|
+
fieldName,
|
|
251
|
+
fieldNodes,
|
|
252
|
+
parentTypeName,
|
|
253
|
+
returnTypeName,
|
|
254
|
+
returnTypeNode,
|
|
255
|
+
path
|
|
256
|
+
);
|
|
203
257
|
try {
|
|
204
|
-
const args = (0, import_values.getArgumentValues)(
|
|
258
|
+
const args = (0, import_values.getArgumentValues)(
|
|
259
|
+
exeContext.resolvers,
|
|
260
|
+
fieldNodes[0],
|
|
261
|
+
exeContext.variableValues
|
|
262
|
+
);
|
|
205
263
|
const contextValue = exeContext.contextValue;
|
|
206
264
|
const result = resolveFn(source, args, contextValue, info);
|
|
207
265
|
let completed;
|
|
208
266
|
if ((0, import_isPromise.isPromise)(result)) {
|
|
209
|
-
completed = result.then(
|
|
267
|
+
completed = result.then(
|
|
268
|
+
(resolved) => completeValue(
|
|
269
|
+
exeContext,
|
|
270
|
+
returnTypeNode,
|
|
271
|
+
fieldNodes,
|
|
272
|
+
info,
|
|
273
|
+
path,
|
|
274
|
+
resolved
|
|
275
|
+
)
|
|
276
|
+
);
|
|
210
277
|
} else {
|
|
211
|
-
completed = completeValue(
|
|
278
|
+
completed = completeValue(
|
|
279
|
+
exeContext,
|
|
280
|
+
returnTypeNode,
|
|
281
|
+
fieldNodes,
|
|
282
|
+
info,
|
|
283
|
+
path,
|
|
284
|
+
result
|
|
285
|
+
);
|
|
212
286
|
}
|
|
213
287
|
if ((0, import_isPromise.isPromise)(completed)) {
|
|
214
288
|
return completed.then(void 0, (rawError) => {
|
|
215
|
-
const error = (0, import_graphql.locatedError)(
|
|
289
|
+
const error = (0, import_graphql.locatedError)(
|
|
290
|
+
rawError,
|
|
291
|
+
fieldNodes,
|
|
292
|
+
(0, import_Path.pathToArray)(path)
|
|
293
|
+
);
|
|
216
294
|
return handleFieldError(error, returnTypeNode, exeContext);
|
|
217
295
|
});
|
|
218
296
|
}
|
|
219
297
|
return completed;
|
|
220
298
|
} catch (rawError) {
|
|
221
|
-
const error = (0, import_graphql.locatedError)(
|
|
299
|
+
const error = (0, import_graphql.locatedError)(
|
|
300
|
+
rawError,
|
|
301
|
+
fieldNodes,
|
|
302
|
+
(0, import_Path.pathToArray)(path)
|
|
303
|
+
);
|
|
222
304
|
return handleFieldError(error, returnTypeNode, exeContext);
|
|
223
305
|
}
|
|
224
306
|
}
|
|
@@ -248,9 +330,18 @@ function completeValue(exeContext, returnTypeNode, fieldNodes, info, path, resul
|
|
|
248
330
|
throw result;
|
|
249
331
|
}
|
|
250
332
|
if (returnTypeNode.kind === import_graphql.Kind.NON_NULL_TYPE) {
|
|
251
|
-
const completed = completeValue(
|
|
333
|
+
const completed = completeValue(
|
|
334
|
+
exeContext,
|
|
335
|
+
returnTypeNode.type,
|
|
336
|
+
fieldNodes,
|
|
337
|
+
info,
|
|
338
|
+
path,
|
|
339
|
+
result
|
|
340
|
+
);
|
|
252
341
|
if (completed === null) {
|
|
253
|
-
throw new Error(
|
|
342
|
+
throw new Error(
|
|
343
|
+
`Cannot return null for non-nullable field ${info.parentTypeName}.${info.fieldName}.`
|
|
344
|
+
);
|
|
254
345
|
}
|
|
255
346
|
return completed;
|
|
256
347
|
}
|
|
@@ -258,7 +349,14 @@ function completeValue(exeContext, returnTypeNode, fieldNodes, info, path, resul
|
|
|
258
349
|
return null;
|
|
259
350
|
}
|
|
260
351
|
if (returnTypeNode.kind === import_graphql.Kind.LIST_TYPE) {
|
|
261
|
-
return completeListValue(
|
|
352
|
+
return completeListValue(
|
|
353
|
+
exeContext,
|
|
354
|
+
returnTypeNode.type,
|
|
355
|
+
fieldNodes,
|
|
356
|
+
info,
|
|
357
|
+
path,
|
|
358
|
+
result
|
|
359
|
+
);
|
|
262
360
|
}
|
|
263
361
|
const returnTypeName = returnTypeNode.name.value;
|
|
264
362
|
let returnType = exeContext.resolvers[returnTypeName];
|
|
@@ -271,16 +369,35 @@ function completeValue(exeContext, returnTypeNode, fieldNodes, info, path, resul
|
|
|
271
369
|
if (returnType instanceof import_graphql.GraphQLInputObjectType) {
|
|
272
370
|
}
|
|
273
371
|
if ((0, import_definition.isUnionResolverType)(returnType) || (0, import_definition.isInterfaceResolverType)(returnType)) {
|
|
274
|
-
return completeAbstractValue(
|
|
372
|
+
return completeAbstractValue(
|
|
373
|
+
exeContext,
|
|
374
|
+
returnType,
|
|
375
|
+
fieldNodes,
|
|
376
|
+
info,
|
|
377
|
+
path,
|
|
378
|
+
result
|
|
379
|
+
);
|
|
275
380
|
}
|
|
276
381
|
if (typeof returnType === "object") {
|
|
277
|
-
return completeObjectValue(
|
|
278
|
-
|
|
279
|
-
|
|
382
|
+
return completeObjectValue(
|
|
383
|
+
exeContext,
|
|
384
|
+
returnTypeName,
|
|
385
|
+
fieldNodes,
|
|
386
|
+
info,
|
|
387
|
+
path,
|
|
388
|
+
result
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
(0, import_invariant.invariant)(
|
|
392
|
+
false,
|
|
393
|
+
"Cannot complete value of unexpected output type: " + (0, import_inspect.inspect)(returnType)
|
|
394
|
+
);
|
|
280
395
|
}
|
|
281
396
|
function completeListValue(exeContext, returnTypeNode, fieldNodes, info, path, result) {
|
|
282
397
|
if (!(0, import_isIterableObject.isIterableObject)(result)) {
|
|
283
|
-
throw new import_graphql.GraphQLError(
|
|
398
|
+
throw new import_graphql.GraphQLError(
|
|
399
|
+
`Expected Iterable, but did not find one for field "${info.parentTypeName}.${info.fieldName}".`
|
|
400
|
+
);
|
|
284
401
|
}
|
|
285
402
|
let containsPromise = false;
|
|
286
403
|
const completedResults = Array.from(result, (item, index) => {
|
|
@@ -288,20 +405,44 @@ function completeListValue(exeContext, returnTypeNode, fieldNodes, info, path, r
|
|
|
288
405
|
try {
|
|
289
406
|
let completedItem;
|
|
290
407
|
if ((0, import_isPromise.isPromise)(item)) {
|
|
291
|
-
completedItem = item.then(
|
|
408
|
+
completedItem = item.then(
|
|
409
|
+
(resolved) => completeValue(
|
|
410
|
+
exeContext,
|
|
411
|
+
returnTypeNode,
|
|
412
|
+
fieldNodes,
|
|
413
|
+
info,
|
|
414
|
+
itemPath,
|
|
415
|
+
resolved
|
|
416
|
+
)
|
|
417
|
+
);
|
|
292
418
|
} else {
|
|
293
|
-
completedItem = completeValue(
|
|
419
|
+
completedItem = completeValue(
|
|
420
|
+
exeContext,
|
|
421
|
+
returnTypeNode,
|
|
422
|
+
fieldNodes,
|
|
423
|
+
info,
|
|
424
|
+
itemPath,
|
|
425
|
+
item
|
|
426
|
+
);
|
|
294
427
|
}
|
|
295
428
|
if ((0, import_isPromise.isPromise)(completedItem)) {
|
|
296
429
|
containsPromise = true;
|
|
297
430
|
return completedItem.then(void 0, (rawError) => {
|
|
298
|
-
const error = (0, import_graphql.locatedError)(
|
|
431
|
+
const error = (0, import_graphql.locatedError)(
|
|
432
|
+
rawError,
|
|
433
|
+
fieldNodes,
|
|
434
|
+
(0, import_Path.pathToArray)(itemPath)
|
|
435
|
+
);
|
|
299
436
|
return handleFieldError(error, returnTypeNode, exeContext);
|
|
300
437
|
});
|
|
301
438
|
}
|
|
302
439
|
return completedItem;
|
|
303
440
|
} catch (rawError) {
|
|
304
|
-
const error = (0, import_graphql.locatedError)(
|
|
441
|
+
const error = (0, import_graphql.locatedError)(
|
|
442
|
+
rawError,
|
|
443
|
+
fieldNodes,
|
|
444
|
+
(0, import_Path.pathToArray)(itemPath)
|
|
445
|
+
);
|
|
305
446
|
return handleFieldError(error, returnTypeNode, exeContext);
|
|
306
447
|
}
|
|
307
448
|
});
|
|
@@ -310,7 +451,9 @@ function completeListValue(exeContext, returnTypeNode, fieldNodes, info, path, r
|
|
|
310
451
|
function completeLeafValue(returnType, result) {
|
|
311
452
|
const serializedResult = returnType.serialize(result);
|
|
312
453
|
if (serializedResult === void 0) {
|
|
313
|
-
throw new Error(
|
|
454
|
+
throw new Error(
|
|
455
|
+
`Expected a value of type "${(0, import_inspect.inspect)(returnType)}" but received: ${(0, import_inspect.inspect)(result)}`
|
|
456
|
+
);
|
|
314
457
|
}
|
|
315
458
|
return serializedResult;
|
|
316
459
|
}
|
|
@@ -320,19 +463,43 @@ function completeAbstractValue(exeContext, returnType, fieldNodes, info, path, r
|
|
|
320
463
|
const contextValue = exeContext.contextValue;
|
|
321
464
|
const runtimeTypeName = resolveTypeFn(result, contextValue, info);
|
|
322
465
|
if ((0, import_isPromise.isPromise)(runtimeTypeName)) {
|
|
323
|
-
return runtimeTypeName.then(
|
|
324
|
-
|
|
325
|
-
|
|
466
|
+
return runtimeTypeName.then(
|
|
467
|
+
(resolvedRuntimeTypeName) => completeObjectValue(
|
|
468
|
+
exeContext,
|
|
469
|
+
ensureValidRuntimeType(resolvedRuntimeTypeName, exeContext),
|
|
470
|
+
fieldNodes,
|
|
471
|
+
info,
|
|
472
|
+
path,
|
|
473
|
+
result
|
|
474
|
+
)
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
return completeObjectValue(
|
|
478
|
+
exeContext,
|
|
479
|
+
ensureValidRuntimeType(runtimeTypeName, exeContext),
|
|
480
|
+
fieldNodes,
|
|
481
|
+
info,
|
|
482
|
+
path,
|
|
483
|
+
result
|
|
484
|
+
);
|
|
326
485
|
}
|
|
327
486
|
function ensureValidRuntimeType(runtimeTypeName, exeContext) {
|
|
328
487
|
if (typeof runtimeTypeName !== "string") {
|
|
329
|
-
throw new import_graphql.GraphQLError(
|
|
488
|
+
throw new import_graphql.GraphQLError(
|
|
489
|
+
`Could not determine runtime type for abstract type ${runtimeTypeName}`
|
|
490
|
+
);
|
|
330
491
|
}
|
|
331
492
|
const runtimeType = exeContext.resolvers[runtimeTypeName];
|
|
332
493
|
if (!runtimeType) {
|
|
333
|
-
throw new import_graphql.GraphQLError(
|
|
494
|
+
throw new import_graphql.GraphQLError(
|
|
495
|
+
`Type "${runtimeTypeName}" does not exist inside the schema.`
|
|
496
|
+
);
|
|
334
497
|
} else if (runtimeType instanceof import_graphql.GraphQLScalarType || runtimeType instanceof import_graphql.GraphQLEnumType || runtimeType instanceof import_graphql.GraphQLInputObjectType || runtimeType.__resolveType) {
|
|
335
|
-
throw new import_graphql.GraphQLError(
|
|
498
|
+
throw new import_graphql.GraphQLError(
|
|
499
|
+
`Given runtime object "${getRuntimeTypeInstanceName(
|
|
500
|
+
runtimeType
|
|
501
|
+
)}" type is not a possible type for "${runtimeTypeName}".`
|
|
502
|
+
);
|
|
336
503
|
} else {
|
|
337
504
|
return runtimeTypeName;
|
|
338
505
|
}
|
|
@@ -353,18 +520,33 @@ function getRuntimeTypeInstanceName(runtimeType) {
|
|
|
353
520
|
}
|
|
354
521
|
}
|
|
355
522
|
function completeObjectValue(exeContext, returnTypeName, fieldNodes, info, path, result) {
|
|
356
|
-
const subFieldNodes = collectSubfields(
|
|
523
|
+
const subFieldNodes = collectSubfields(
|
|
524
|
+
exeContext,
|
|
525
|
+
returnTypeName,
|
|
526
|
+
fieldNodes
|
|
527
|
+
);
|
|
357
528
|
return executeFields(exeContext, returnTypeName, result, path, subFieldNodes);
|
|
358
529
|
}
|
|
359
530
|
function invalidReturnTypeError(returnType, result, fieldNodes) {
|
|
360
|
-
return new import_graphql.GraphQLError(
|
|
531
|
+
return new import_graphql.GraphQLError(
|
|
532
|
+
`Expected value of type "${returnType.name}" but got: ${(0, import_inspect.inspect)(result)}.`,
|
|
533
|
+
fieldNodes
|
|
534
|
+
);
|
|
361
535
|
}
|
|
362
536
|
function collectSubfields(exeContext, returnTypeName, fieldNodes) {
|
|
363
537
|
let subFieldNodes = /* @__PURE__ */ new Map();
|
|
364
538
|
const visitedFragmentNames = /* @__PURE__ */ new Set();
|
|
365
539
|
for (const node of fieldNodes) {
|
|
366
540
|
if (node.selectionSet) {
|
|
367
|
-
subFieldNodes = (0, import_collectFields.collectFields)(
|
|
541
|
+
subFieldNodes = (0, import_collectFields.collectFields)(
|
|
542
|
+
exeContext.resolvers,
|
|
543
|
+
exeContext.fragments,
|
|
544
|
+
exeContext.variableValues,
|
|
545
|
+
returnTypeName,
|
|
546
|
+
node.selectionSet,
|
|
547
|
+
subFieldNodes,
|
|
548
|
+
visitedFragmentNames
|
|
549
|
+
);
|
|
368
550
|
}
|
|
369
551
|
}
|
|
370
552
|
return subFieldNodes;
|