@graphitation/supermassive 3.0.0-alpha.5 → 3.0.0-alpha.7
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/CHANGELOG.md +18 -2
- package/lib/benchmarks/index.js.map +2 -2
- package/lib/benchmarks/index.mjs.map +2 -2
- package/lib/collectFields.d.ts.map +1 -1
- package/lib/collectFields.js +6 -5
- package/lib/collectFields.js.map +2 -2
- package/lib/collectFields.mjs +6 -5
- package/lib/collectFields.mjs.map +2 -2
- package/lib/executeWithoutSchema.d.ts +1 -3
- package/lib/executeWithoutSchema.d.ts.map +1 -1
- package/lib/executeWithoutSchema.js +153 -69
- package/lib/executeWithoutSchema.js.map +2 -2
- package/lib/executeWithoutSchema.mjs +143 -71
- package/lib/executeWithoutSchema.mjs.map +2 -2
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +2 -2
- package/lib/index.mjs +10 -2
- package/lib/index.mjs.map +2 -2
- package/lib/schema/definition.d.ts +43 -33
- package/lib/schema/definition.d.ts.map +1 -1
- package/lib/schema/definition.js +284 -9
- package/lib/schema/definition.js.map +2 -2
- package/lib/schema/definition.mjs +284 -55
- package/lib/schema/definition.mjs.map +3 -3
- package/lib/schema/directives.d.ts.map +1 -1
- package/lib/schema/directives.js +3 -3
- package/lib/schema/directives.js.map +2 -2
- package/lib/schema/directives.mjs +4 -4
- package/lib/schema/directives.mjs.map +2 -2
- package/lib/schema/reference.d.ts +3 -1
- package/lib/schema/reference.d.ts.map +1 -1
- package/lib/schema/reference.js.map +2 -2
- package/lib/schema/reference.mjs.map +2 -2
- package/lib/schema/resolvers.d.ts +10 -4
- package/lib/schema/resolvers.d.ts.map +1 -1
- package/lib/schema/resolvers.js +92 -9
- package/lib/schema/resolvers.js.map +2 -2
- package/lib/schema/resolvers.mjs +99 -9
- package/lib/schema/resolvers.mjs.map +2 -2
- package/lib/types.d.ts +25 -2
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utilities/coerceInputValue.d.ts +3 -3
- package/lib/utilities/coerceInputValue.d.ts.map +1 -1
- package/lib/utilities/coerceInputValue.js +17 -12
- package/lib/utilities/coerceInputValue.js.map +2 -2
- package/lib/utilities/coerceInputValue.mjs +22 -12
- package/lib/utilities/coerceInputValue.mjs.map +2 -2
- package/lib/utilities/decodeASTSchema.d.ts.map +1 -1
- package/lib/utilities/decodeASTSchema.js +32 -40
- package/lib/utilities/decodeASTSchema.js.map +2 -2
- package/lib/utilities/decodeASTSchema.mjs +51 -49
- package/lib/utilities/decodeASTSchema.mjs.map +2 -2
- package/lib/utilities/encodeASTSchema.d.ts.map +1 -1
- package/lib/utilities/encodeASTSchema.js +16 -20
- package/lib/utilities/encodeASTSchema.js.map +2 -2
- package/lib/utilities/encodeASTSchema.mjs +22 -21
- package/lib/utilities/encodeASTSchema.mjs.map +2 -2
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.d.ts.map +1 -1
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.js +20 -22
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.js.map +2 -2
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.mjs +35 -29
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.mjs.map +2 -2
- package/lib/utilities/mergeResolvers.js +1 -2
- package/lib/utilities/mergeResolvers.js.map +2 -2
- package/lib/utilities/mergeResolvers.mjs +1 -2
- package/lib/utilities/mergeResolvers.mjs.map +2 -2
- package/lib/utilities/mergeSchemaDefinitions.d.ts.map +1 -1
- package/lib/utilities/mergeSchemaDefinitions.js +18 -28
- package/lib/utilities/mergeSchemaDefinitions.js.map +2 -2
- package/lib/utilities/mergeSchemaDefinitions.mjs +28 -34
- package/lib/utilities/mergeSchemaDefinitions.mjs.map +2 -2
- package/lib/utilities/valueFromAST.d.ts +3 -3
- package/lib/utilities/valueFromAST.d.ts.map +1 -1
- package/lib/utilities/valueFromAST.js +23 -10
- package/lib/utilities/valueFromAST.js.map +2 -2
- package/lib/utilities/valueFromAST.mjs +13 -10
- package/lib/utilities/valueFromAST.mjs.map +2 -2
- package/lib/values.d.ts +2 -2
- package/lib/values.d.ts.map +1 -1
- package/lib/values.js +14 -14
- package/lib/values.js.map +2 -2
- package/lib/values.mjs +21 -14
- package/lib/values.mjs.map +2 -2
- package/package.json +1 -1
- package/lib/schema/fragment.d.ts +0 -63
- package/lib/schema/fragment.d.ts.map +0 -1
- package/lib/schema/fragment.js +0 -295
- package/lib/schema/fragment.js.map +0 -7
- package/lib/schema/fragment.mjs +0 -292
- package/lib/schema/fragment.mjs.map +0 -7
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __defProps = Object.defineProperties;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
8
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
11
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
12
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -32,6 +34,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
32
34
|
}
|
|
33
35
|
return to;
|
|
34
36
|
};
|
|
37
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
38
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
39
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
40
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
41
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
42
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
43
|
+
mod
|
|
44
|
+
));
|
|
35
45
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
46
|
var __async = (__this, __arguments, generator) => {
|
|
37
47
|
return new Promise((resolve, reject) => {
|
|
@@ -82,14 +92,15 @@ var import_isAsyncIterable = require("./jsutils/isAsyncIterable");
|
|
|
82
92
|
var import_mapAsyncIterator = require("./utilities/mapAsyncIterator");
|
|
83
93
|
var import_directives = require("./schema/directives");
|
|
84
94
|
var import_memoize3 = require("./jsutils/memoize3");
|
|
85
|
-
var import_fragment = require("./schema/fragment");
|
|
86
95
|
var import_reference = require("./schema/reference");
|
|
96
|
+
var Definitions = __toESM(require("./schema/definition"));
|
|
97
|
+
var Resolvers = __toESM(require("./schema/resolvers"));
|
|
87
98
|
const collectSubfields = (0, import_memoize3.memoize3)(
|
|
88
99
|
(exeContext, returnTypeName, fieldGroup) => (0, import_collectFields.collectSubfields)(exeContext, returnTypeName.name, fieldGroup)
|
|
89
100
|
);
|
|
90
101
|
function executeWithoutSchema(args) {
|
|
91
102
|
const exeContext = buildExecutionContext(args);
|
|
92
|
-
if (!("
|
|
103
|
+
if (!("schemaFragment" in exeContext)) {
|
|
93
104
|
return { errors: exeContext };
|
|
94
105
|
} else {
|
|
95
106
|
return executeOperation(exeContext);
|
|
@@ -105,7 +116,6 @@ function assertValidExecutionArguments(document, rawVariableValues) {
|
|
|
105
116
|
function buildExecutionContext(args) {
|
|
106
117
|
var _a, _b;
|
|
107
118
|
const {
|
|
108
|
-
// resolvers,
|
|
109
119
|
schemaFragment,
|
|
110
120
|
schemaFragmentLoader,
|
|
111
121
|
document,
|
|
@@ -150,9 +160,8 @@ function buildExecutionContext(args) {
|
|
|
150
160
|
return [new import_graphql.GraphQLError("Must provide an operation.")];
|
|
151
161
|
}
|
|
152
162
|
const variableDefinitions = (_b = operation.variableDefinitions) != null ? _b : [];
|
|
153
|
-
const partialSchema = new import_fragment.PartialSchema(schemaFragment);
|
|
154
163
|
const coercedVariableValues = (0, import_values.getVariableValues)(
|
|
155
|
-
|
|
164
|
+
schemaFragment,
|
|
156
165
|
variableDefinitions,
|
|
157
166
|
variableValues != null ? variableValues : {},
|
|
158
167
|
{ maxErrors: 50 }
|
|
@@ -161,7 +170,6 @@ function buildExecutionContext(args) {
|
|
|
161
170
|
return coercedVariableValues.errors;
|
|
162
171
|
}
|
|
163
172
|
return {
|
|
164
|
-
partialSchema,
|
|
165
173
|
schemaFragment,
|
|
166
174
|
schemaFragmentLoader,
|
|
167
175
|
fragments,
|
|
@@ -325,8 +333,13 @@ function executeFields(exeContext, parentTypeName, sourceValue, path, groupedFie
|
|
|
325
333
|
return (0, import_promiseForObject.promiseForObject)(results);
|
|
326
334
|
}
|
|
327
335
|
function executeField(exeContext, parentTypeName, source, fieldGroup, path, incrementalDataRecord) {
|
|
336
|
+
const schemaFragment = exeContext.schemaFragment;
|
|
328
337
|
const fieldName = fieldGroup[0].name.value;
|
|
329
|
-
const fieldDef =
|
|
338
|
+
const fieldDef = Definitions.getField(
|
|
339
|
+
schemaFragment.definitions,
|
|
340
|
+
parentTypeName,
|
|
341
|
+
fieldName
|
|
342
|
+
);
|
|
330
343
|
if (fieldDef !== void 0) {
|
|
331
344
|
return resolveAndCompleteField(
|
|
332
345
|
exeContext,
|
|
@@ -338,30 +351,50 @@ function executeField(exeContext, parentTypeName, source, fieldGroup, path, incr
|
|
|
338
351
|
incrementalDataRecord
|
|
339
352
|
);
|
|
340
353
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
}
|
|
344
|
-
return exeContext.schemaFragmentLoader(exeContext.schemaFragment, exeContext.contextValue, {
|
|
345
|
-
kind: "byField",
|
|
354
|
+
const loading = requestSchemaFragment(exeContext, {
|
|
355
|
+
kind: "ReturnType",
|
|
346
356
|
parentTypeName,
|
|
347
357
|
fieldName
|
|
348
|
-
})
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
358
|
+
});
|
|
359
|
+
if (!loading) {
|
|
360
|
+
return void 0;
|
|
361
|
+
}
|
|
362
|
+
return loading.then(() => {
|
|
363
|
+
const fieldDef2 = Definitions.getField(
|
|
364
|
+
exeContext.schemaFragment.definitions,
|
|
353
365
|
parentTypeName,
|
|
354
366
|
fieldName
|
|
355
367
|
);
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
368
|
+
if (fieldDef2 !== void 0) {
|
|
369
|
+
return resolveAndCompleteField(
|
|
370
|
+
exeContext,
|
|
371
|
+
parentTypeName,
|
|
372
|
+
fieldDef2,
|
|
373
|
+
fieldGroup,
|
|
374
|
+
path,
|
|
375
|
+
source,
|
|
376
|
+
incrementalDataRecord
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
return void 0;
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
function requestSchemaFragment(exeContext, request) {
|
|
383
|
+
if (!exeContext.schemaFragmentLoader) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
return exeContext.schemaFragmentLoader(
|
|
387
|
+
exeContext.schemaFragment,
|
|
388
|
+
exeContext.contextValue,
|
|
389
|
+
request
|
|
390
|
+
).then(({ mergedFragment, mergedContextValue }) => {
|
|
391
|
+
if (exeContext.schemaFragment.schemaId !== mergedFragment.schemaId) {
|
|
392
|
+
throw new Error(
|
|
393
|
+
`Cannot use new schema fragment: old and new fragments describe different schemas: ${exeContext.schemaFragment.schemaId} vs. ${mergedFragment.schemaId}`
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
exeContext.contextValue = mergedContextValue != null ? mergedContextValue : exeContext.contextValue;
|
|
397
|
+
exeContext.schemaFragment = mergedFragment;
|
|
365
398
|
});
|
|
366
399
|
}
|
|
367
400
|
function createSourceEventStream(exeContext) {
|
|
@@ -377,21 +410,29 @@ function createSourceEventStream(exeContext) {
|
|
|
377
410
|
}
|
|
378
411
|
function executeSubscriptionImpl(exeContext) {
|
|
379
412
|
var _a;
|
|
380
|
-
const { operation, rootValue,
|
|
413
|
+
const { operation, rootValue, schemaFragment } = exeContext;
|
|
381
414
|
const rootTypeName = getOperationRootTypeName(operation);
|
|
382
415
|
const { groupedFieldSet } = (0, import_collectFields.collectFields)(exeContext, rootTypeName);
|
|
383
416
|
const firstRootField = groupedFieldSet.entries().next().value;
|
|
384
417
|
const [responseName, fieldGroup] = firstRootField;
|
|
385
418
|
const fieldName = fieldGroup[0].name.value;
|
|
386
|
-
const fieldDef =
|
|
419
|
+
const fieldDef = Definitions.getField(
|
|
420
|
+
schemaFragment.definitions,
|
|
421
|
+
rootTypeName,
|
|
422
|
+
fieldName
|
|
423
|
+
);
|
|
387
424
|
if (!fieldDef) {
|
|
388
425
|
throw new import_graphql.GraphQLError(
|
|
389
426
|
`The subscription field "${fieldName}" is not defined.`,
|
|
390
427
|
{ nodes: fieldGroup }
|
|
391
428
|
);
|
|
392
429
|
}
|
|
393
|
-
const returnTypeRef =
|
|
394
|
-
const resolveFn = (_a =
|
|
430
|
+
const returnTypeRef = Definitions.getFieldTypeReference(fieldDef);
|
|
431
|
+
const resolveFn = (_a = Resolvers.getSubscriptionFieldResolver(
|
|
432
|
+
schemaFragment,
|
|
433
|
+
rootTypeName,
|
|
434
|
+
fieldName
|
|
435
|
+
)) != null ? _a : exeContext.subscribeFieldResolver;
|
|
395
436
|
const path = (0, import_Path.addPath)(void 0, responseName, rootTypeName);
|
|
396
437
|
const info = buildResolveInfo(
|
|
397
438
|
exeContext,
|
|
@@ -485,8 +526,12 @@ function handleFieldError(rawError, exeContext, returnTypeRef, fieldGroup, path,
|
|
|
485
526
|
function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fieldGroup, path, source, incrementalDataRecord) {
|
|
486
527
|
var _a;
|
|
487
528
|
const fieldName = fieldGroup[0].name.value;
|
|
488
|
-
const returnTypeRef =
|
|
489
|
-
const resolveFn = (_a =
|
|
529
|
+
const returnTypeRef = Definitions.getFieldTypeReference(fieldDefinition);
|
|
530
|
+
const resolveFn = (_a = Resolvers.getFieldResolver(
|
|
531
|
+
exeContext.schemaFragment,
|
|
532
|
+
parentTypeName,
|
|
533
|
+
fieldName
|
|
534
|
+
)) != null ? _a : exeContext.fieldResolver;
|
|
490
535
|
const info = buildResolveInfo(
|
|
491
536
|
exeContext,
|
|
492
537
|
fieldName,
|
|
@@ -626,13 +671,13 @@ function completeValue(exeContext, returnTypeRef, fieldGroup, info, path, result
|
|
|
626
671
|
incrementalDataRecord
|
|
627
672
|
);
|
|
628
673
|
}
|
|
629
|
-
const
|
|
674
|
+
const { schemaFragment } = exeContext;
|
|
630
675
|
const returnTypeName = (0, import_reference.typeNameFromReference)(returnTypeRef);
|
|
631
|
-
const leafType =
|
|
676
|
+
const leafType = Resolvers.getLeafTypeResolver(schemaFragment, returnTypeRef);
|
|
632
677
|
if (leafType) {
|
|
633
678
|
return completeLeafValue(leafType, result);
|
|
634
679
|
}
|
|
635
|
-
if (
|
|
680
|
+
if (Definitions.isAbstractType(schemaFragment.definitions, returnTypeRef)) {
|
|
636
681
|
return completeAbstractValue(
|
|
637
682
|
exeContext,
|
|
638
683
|
returnTypeName,
|
|
@@ -643,7 +688,7 @@ function completeValue(exeContext, returnTypeRef, fieldGroup, info, path, result
|
|
|
643
688
|
incrementalDataRecord
|
|
644
689
|
);
|
|
645
690
|
}
|
|
646
|
-
if (
|
|
691
|
+
if (Definitions.isObjectType(schemaFragment.definitions, returnTypeRef)) {
|
|
647
692
|
return completeObjectValue(
|
|
648
693
|
exeContext,
|
|
649
694
|
returnTypeName,
|
|
@@ -894,21 +939,32 @@ function completeLeafValue(returnType, result) {
|
|
|
894
939
|
}
|
|
895
940
|
function completeAbstractValue(exeContext, returnTypeName, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
896
941
|
var _a;
|
|
897
|
-
const
|
|
942
|
+
const { schemaFragment } = exeContext;
|
|
943
|
+
const resolveTypeFn = (_a = Resolvers.getAbstractTypeResolver(schemaFragment, returnTypeName)) != null ? _a : exeContext.typeResolver;
|
|
898
944
|
const contextValue = exeContext.contextValue;
|
|
899
945
|
const runtimeTypeName = resolveTypeFn(result, contextValue, info);
|
|
900
|
-
|
|
901
|
-
|
|
946
|
+
const validatedRuntimeTypeName = (0, import_isPromise.isPromise)(runtimeTypeName) ? runtimeTypeName.then(
|
|
947
|
+
(resolvedRuntimeTypeName) => ensureValidRuntimeType(
|
|
948
|
+
resolvedRuntimeTypeName,
|
|
949
|
+
exeContext,
|
|
950
|
+
returnTypeName,
|
|
951
|
+
fieldGroup,
|
|
952
|
+
info,
|
|
953
|
+
result
|
|
954
|
+
)
|
|
955
|
+
) : ensureValidRuntimeType(
|
|
956
|
+
runtimeTypeName,
|
|
957
|
+
exeContext,
|
|
958
|
+
returnTypeName,
|
|
959
|
+
fieldGroup,
|
|
960
|
+
info,
|
|
961
|
+
result
|
|
962
|
+
);
|
|
963
|
+
if ((0, import_isPromise.isPromise)(validatedRuntimeTypeName)) {
|
|
964
|
+
return validatedRuntimeTypeName.then(
|
|
902
965
|
(resolvedRuntimeTypeName) => completeObjectValue(
|
|
903
966
|
exeContext,
|
|
904
|
-
|
|
905
|
-
resolvedRuntimeTypeName,
|
|
906
|
-
exeContext,
|
|
907
|
-
returnTypeName,
|
|
908
|
-
fieldGroup,
|
|
909
|
-
info,
|
|
910
|
-
result
|
|
911
|
-
),
|
|
967
|
+
resolvedRuntimeTypeName,
|
|
912
968
|
fieldGroup,
|
|
913
969
|
path,
|
|
914
970
|
result,
|
|
@@ -918,14 +974,7 @@ function completeAbstractValue(exeContext, returnTypeName, fieldGroup, info, pat
|
|
|
918
974
|
}
|
|
919
975
|
return completeObjectValue(
|
|
920
976
|
exeContext,
|
|
921
|
-
|
|
922
|
-
runtimeTypeName,
|
|
923
|
-
exeContext,
|
|
924
|
-
returnTypeName,
|
|
925
|
-
fieldGroup,
|
|
926
|
-
info,
|
|
927
|
-
result
|
|
928
|
-
),
|
|
977
|
+
validatedRuntimeTypeName,
|
|
929
978
|
fieldGroup,
|
|
930
979
|
path,
|
|
931
980
|
result,
|
|
@@ -944,37 +993,72 @@ function ensureValidRuntimeType(runtimeTypeName, exeContext, returnTypeName, fie
|
|
|
944
993
|
`Abstract type "${returnTypeName}" must resolve to an Object type at runtime for field "${info.returnTypeName}.${info.fieldName}" with value ${(0, import_inspect.inspect)(result)}, received "${(0, import_inspect.inspect)(runtimeTypeName)}".`
|
|
945
994
|
);
|
|
946
995
|
}
|
|
947
|
-
const
|
|
948
|
-
const
|
|
949
|
-
|
|
950
|
-
|
|
996
|
+
const strictInterfaceValidation = !!exeContext.schemaFragmentLoader;
|
|
997
|
+
const isDefinedType = Definitions.isDefined(
|
|
998
|
+
exeContext.schemaFragment.definitions,
|
|
999
|
+
runtimeTypeName
|
|
1000
|
+
);
|
|
1001
|
+
const loading = !isDefinedType ? requestSchemaFragment(exeContext, {
|
|
1002
|
+
kind: "RuntimeType",
|
|
1003
|
+
abstractTypeName: returnTypeName,
|
|
1004
|
+
runtimeTypeName
|
|
1005
|
+
}) : void 0;
|
|
1006
|
+
return loading ? loading.then(
|
|
1007
|
+
() => ensureValidRuntimeTypeImpl(
|
|
1008
|
+
runtimeTypeName,
|
|
1009
|
+
exeContext,
|
|
1010
|
+
returnTypeName,
|
|
1011
|
+
fieldGroup,
|
|
1012
|
+
strictInterfaceValidation
|
|
1013
|
+
)
|
|
1014
|
+
) : ensureValidRuntimeTypeImpl(
|
|
1015
|
+
runtimeTypeName,
|
|
1016
|
+
exeContext,
|
|
1017
|
+
returnTypeName,
|
|
1018
|
+
fieldGroup,
|
|
1019
|
+
strictInterfaceValidation
|
|
1020
|
+
);
|
|
1021
|
+
}
|
|
1022
|
+
function ensureValidRuntimeTypeImpl(runtimeTypeName, exeContext, returnTypeName, fieldGroup, strictInterfaceValidation) {
|
|
1023
|
+
const definitions = exeContext.schemaFragment.definitions;
|
|
1024
|
+
const union = Definitions.getUnionType(definitions, returnTypeName);
|
|
1025
|
+
if (union || strictInterfaceValidation) {
|
|
1026
|
+
if (!Definitions.isDefined(definitions, runtimeTypeName)) {
|
|
951
1027
|
throw new import_graphql.GraphQLError(
|
|
952
|
-
`Abstract type "${returnTypeName}" was resolved to a
|
|
1028
|
+
`Abstract type "${returnTypeName}" was resolved to a type "${runtimeTypeName}" that does not exist inside the schema.`,
|
|
953
1029
|
{ nodes: fieldGroup }
|
|
954
1030
|
);
|
|
955
1031
|
}
|
|
956
|
-
|
|
957
|
-
} else {
|
|
958
|
-
if (!partialSchema.isDefined(runtimeTypeName)) {
|
|
1032
|
+
if (!Definitions.isObjectType(definitions, runtimeTypeName)) {
|
|
959
1033
|
throw new import_graphql.GraphQLError(
|
|
960
|
-
`Abstract type "${returnTypeName}" was resolved to a type "${runtimeTypeName}"
|
|
1034
|
+
`Abstract type "${returnTypeName}" was resolved to a non-object type "${runtimeTypeName}".`,
|
|
961
1035
|
{ nodes: fieldGroup }
|
|
962
1036
|
);
|
|
963
1037
|
}
|
|
964
|
-
if (!
|
|
1038
|
+
if (!Definitions.isSubType(definitions, returnTypeName, runtimeTypeName)) {
|
|
965
1039
|
throw new import_graphql.GraphQLError(
|
|
966
|
-
`
|
|
1040
|
+
`Runtime Object type "${runtimeTypeName}" is not a possible type for "${returnTypeName}".`,
|
|
967
1041
|
{ nodes: fieldGroup }
|
|
968
1042
|
);
|
|
969
1043
|
}
|
|
970
|
-
|
|
1044
|
+
return runtimeTypeName;
|
|
1045
|
+
}
|
|
1046
|
+
const iface = Definitions.getInterfaceType(definitions, returnTypeName);
|
|
1047
|
+
if (iface) {
|
|
1048
|
+
if (Definitions.isDefined(definitions, runtimeTypeName) && !Definitions.isObjectType(definitions, runtimeTypeName)) {
|
|
971
1049
|
throw new import_graphql.GraphQLError(
|
|
972
|
-
`
|
|
1050
|
+
`Abstract type "${returnTypeName}" was resolved to a non-object type "${runtimeTypeName}".`,
|
|
973
1051
|
{ nodes: fieldGroup }
|
|
974
1052
|
);
|
|
975
1053
|
}
|
|
1054
|
+
Definitions.addInterfaceImplementation(
|
|
1055
|
+
definitions,
|
|
1056
|
+
returnTypeName,
|
|
1057
|
+
runtimeTypeName
|
|
1058
|
+
);
|
|
1059
|
+
return runtimeTypeName;
|
|
976
1060
|
}
|
|
977
|
-
|
|
1061
|
+
(0, import_invariant.invariant)(false, `${returnTypeName} is not an abstract type`);
|
|
978
1062
|
}
|
|
979
1063
|
function completeObjectValue(exeContext, returnTypeName, fieldGroup, path, result, incrementalDataRecord) {
|
|
980
1064
|
return collectAndExecuteSubfields(
|