@graphitation/supermassive 3.0.0-alpha.1 → 3.0.0-alpha.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/CHANGELOG.md +10 -2
- package/lib/__testUtils__/execute.d.ts +13 -0
- package/lib/__testUtils__/execute.d.ts.map +1 -0
- package/lib/__testUtils__/execute.js +196 -0
- package/lib/__testUtils__/execute.js.map +7 -0
- package/lib/__testUtils__/execute.mjs +174 -0
- package/lib/__testUtils__/execute.mjs.map +7 -0
- package/lib/benchmarks/index.js +10 -19
- package/lib/benchmarks/index.js.map +3 -3
- package/lib/benchmarks/index.mjs +11 -22
- package/lib/benchmarks/index.mjs.map +2 -2
- package/lib/collectFields.d.ts +4 -9
- package/lib/collectFields.d.ts.map +1 -1
- package/lib/collectFields.js +38 -99
- package/lib/collectFields.js.map +2 -2
- package/lib/collectFields.mjs +41 -100
- package/lib/collectFields.mjs.map +2 -2
- package/lib/executeWithSchema.d.ts +1 -1
- package/lib/executeWithSchema.d.ts.map +1 -1
- package/lib/executeWithSchema.js +7 -13
- package/lib/executeWithSchema.js.map +2 -2
- package/lib/executeWithSchema.mjs +9 -20
- package/lib/executeWithSchema.mjs.map +2 -2
- package/lib/executeWithoutSchema.d.ts +5 -5
- package/lib/executeWithoutSchema.d.ts.map +1 -1
- package/lib/executeWithoutSchema.js +175 -227
- package/lib/executeWithoutSchema.js.map +2 -2
- package/lib/executeWithoutSchema.mjs +176 -228
- package/lib/executeWithoutSchema.mjs.map +2 -2
- package/lib/index.d.ts +2 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -7
- package/lib/index.js.map +2 -2
- package/lib/index.mjs +0 -10
- package/lib/index.mjs.map +2 -2
- package/lib/schema/definition.d.ts +95 -0
- package/lib/schema/definition.d.ts.map +1 -0
- package/lib/schema/definition.js +77 -0
- package/lib/schema/definition.js.map +7 -0
- package/lib/schema/definition.mjs +58 -0
- package/lib/schema/definition.mjs.map +7 -0
- package/lib/schema/directives.d.ts +41 -0
- package/lib/schema/directives.d.ts.map +1 -0
- package/lib/schema/directives.js +82 -0
- package/lib/schema/directives.js.map +7 -0
- package/lib/schema/directives.mjs +65 -0
- package/lib/schema/directives.mjs.map +7 -0
- package/lib/schema/fragment.d.ts +41 -0
- package/lib/schema/fragment.d.ts.map +1 -0
- package/lib/schema/fragment.js +270 -0
- package/lib/schema/fragment.js.map +7 -0
- package/lib/schema/fragment.mjs +267 -0
- package/lib/schema/fragment.mjs.map +7 -0
- package/lib/schema/reference.d.ts +12 -0
- package/lib/schema/reference.d.ts.map +1 -0
- package/lib/schema/reference.js +137 -0
- package/lib/schema/reference.js.map +7 -0
- package/lib/schema/reference.mjs +118 -0
- package/lib/schema/reference.mjs.map +7 -0
- package/lib/schema/resolvers.d.ts +9 -0
- package/lib/schema/resolvers.d.ts.map +1 -0
- package/lib/schema/resolvers.js +47 -0
- package/lib/schema/resolvers.js.map +7 -0
- package/lib/schema/resolvers.mjs +35 -0
- package/lib/schema/resolvers.mjs.map +7 -0
- package/lib/subscribeWithSchema.d.ts +1 -1
- package/lib/subscribeWithSchema.d.ts.map +1 -1
- package/lib/subscribeWithSchema.js +7 -13
- package/lib/subscribeWithSchema.js.map +2 -2
- package/lib/subscribeWithSchema.mjs +9 -20
- package/lib/subscribeWithSchema.mjs.map +2 -2
- package/lib/types.d.ts +10 -24
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +2 -2
- package/lib/types.mjs.map +2 -2
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.d.ts +9 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.d.ts.map +1 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.js +303 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.js.map +7 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.mjs +317 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.mjs.map +7 -0
- package/lib/{supermassive-ast → utilities}/annotateDocumentGraphQLTransform.d.ts +1 -1
- package/lib/utilities/annotateDocumentGraphQLTransform.d.ts.map +1 -0
- package/lib/{supermassive-ast → utilities}/annotateDocumentGraphQLTransform.js +3 -3
- package/lib/utilities/annotateDocumentGraphQLTransform.js.map +7 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.mjs +17 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.mjs.map +7 -0
- package/lib/utilities/coerceInputValue.d.ts +10 -0
- package/lib/utilities/coerceInputValue.d.ts.map +1 -0
- package/lib/utilities/coerceInputValue.js +181 -0
- package/lib/utilities/coerceInputValue.js.map +7 -0
- package/lib/utilities/coerceInputValue.mjs +167 -0
- package/lib/utilities/coerceInputValue.mjs.map +7 -0
- package/lib/utilities/decodeASTSchema.d.ts +7 -0
- package/lib/utilities/decodeASTSchema.d.ts.map +1 -0
- package/lib/utilities/decodeASTSchema.js +243 -0
- package/lib/utilities/decodeASTSchema.js.map +7 -0
- package/lib/utilities/decodeASTSchema.mjs +242 -0
- package/lib/utilities/decodeASTSchema.mjs.map +7 -0
- package/lib/utilities/encodeASTSchema.d.ts +4 -0
- package/lib/utilities/encodeASTSchema.d.ts.map +1 -0
- package/lib/utilities/encodeASTSchema.js +122 -0
- package/lib/utilities/encodeASTSchema.js.map +7 -0
- package/lib/utilities/encodeASTSchema.mjs +105 -0
- package/lib/utilities/encodeASTSchema.mjs.map +7 -0
- package/lib/utilities/getSchemaFragment.d.ts +4 -0
- package/lib/utilities/getSchemaFragment.d.ts.map +1 -0
- package/lib/utilities/getSchemaFragment.js +38 -0
- package/lib/utilities/getSchemaFragment.js.map +7 -0
- package/lib/utilities/getSchemaFragment.mjs +22 -0
- package/lib/utilities/getSchemaFragment.mjs.map +7 -0
- package/lib/utilities/makeReadableErrorPath.d.ts +3 -0
- package/lib/utilities/makeReadableErrorPath.d.ts.map +1 -0
- package/lib/utilities/makeReadableErrorPath.js +47 -0
- package/lib/utilities/makeReadableErrorPath.js.map +7 -0
- package/lib/utilities/makeReadableErrorPath.mjs +28 -0
- package/lib/utilities/makeReadableErrorPath.mjs.map +7 -0
- package/lib/utilities/mergeDefinitions.d.ts +8 -0
- package/lib/utilities/mergeDefinitions.d.ts.map +1 -0
- package/lib/utilities/mergeDefinitions.js +126 -0
- package/lib/utilities/mergeDefinitions.js.map +7 -0
- package/lib/utilities/mergeDefinitions.mjs +114 -0
- package/lib/utilities/mergeDefinitions.mjs.map +7 -0
- package/lib/utilities/typeNameFromAST.d.ts +1 -1
- package/lib/utilities/typeNameFromAST.d.ts.map +1 -1
- package/lib/utilities/typeNameFromAST.js.map +2 -2
- package/lib/utilities/typeNameFromAST.mjs.map +2 -2
- package/lib/utilities/valueFromAST.d.ts +27 -0
- package/lib/utilities/valueFromAST.d.ts.map +1 -0
- package/lib/utilities/valueFromAST.js +139 -0
- package/lib/utilities/valueFromAST.js.map +7 -0
- package/lib/utilities/valueFromAST.mjs +125 -0
- package/lib/utilities/valueFromAST.mjs.map +7 -0
- package/lib/utilities/valueFromASTUntyped.d.ts +21 -0
- package/lib/utilities/valueFromASTUntyped.d.ts.map +1 -0
- package/lib/utilities/valueFromASTUntyped.js +51 -0
- package/lib/utilities/valueFromASTUntyped.js.map +7 -0
- package/lib/utilities/valueFromASTUntyped.mjs +32 -0
- package/lib/utilities/valueFromASTUntyped.mjs.map +7 -0
- package/lib/values.d.ts +8 -12
- package/lib/values.d.ts.map +1 -1
- package/lib/values.js +75 -63
- package/lib/values.js.map +2 -2
- package/lib/values.mjs +77 -71
- package/lib/values.mjs.map +2 -2
- package/package.json +8 -6
- package/lib/definition.d.ts +0 -7
- package/lib/definition.d.ts.map +0 -1
- package/lib/definition.js +0 -59
- package/lib/definition.js.map +0 -7
- package/lib/definition.mjs +0 -40
- package/lib/definition.mjs.map +0 -7
- package/lib/directives.d.ts +0 -8
- package/lib/directives.d.ts.map +0 -1
- package/lib/directives.js +0 -47
- package/lib/directives.js.map +0 -7
- package/lib/directives.mjs +0 -37
- package/lib/directives.mjs.map +0 -7
- package/lib/extractImplicitTypesRuntime.d.ts +0 -4
- package/lib/extractImplicitTypesRuntime.d.ts.map +0 -1
- package/lib/extractImplicitTypesRuntime.js +0 -123
- package/lib/extractImplicitTypesRuntime.js.map +0 -7
- package/lib/extractImplicitTypesRuntime.mjs +0 -114
- package/lib/extractImplicitTypesRuntime.mjs.map +0 -7
- package/lib/supermassive-ast/TypedAST.d.ts +0 -370
- package/lib/supermassive-ast/TypedAST.d.ts.map +0 -1
- package/lib/supermassive-ast/TypedAST.js +0 -29
- package/lib/supermassive-ast/TypedAST.js.map +0 -7
- package/lib/supermassive-ast/TypedAST.mjs +0 -10
- package/lib/supermassive-ast/TypedAST.mjs.map +0 -7
- package/lib/supermassive-ast/addTypesToRequestDocument.d.ts +0 -56
- package/lib/supermassive-ast/addTypesToRequestDocument.d.ts.map +0 -1
- package/lib/supermassive-ast/addTypesToRequestDocument.js +0 -473
- package/lib/supermassive-ast/addTypesToRequestDocument.js.map +0 -7
- package/lib/supermassive-ast/addTypesToRequestDocument.mjs +0 -463
- package/lib/supermassive-ast/addTypesToRequestDocument.mjs.map +0 -7
- package/lib/supermassive-ast/annotateDocumentGraphQLTransform.d.ts.map +0 -1
- package/lib/supermassive-ast/annotateDocumentGraphQLTransform.js.map +0 -7
- package/lib/supermassive-ast/annotateDocumentGraphQLTransform.mjs +0 -17
- package/lib/supermassive-ast/annotateDocumentGraphQLTransform.mjs.map +0 -7
- package/lib/supermassive-ast/directives.d.ts +0 -36
- package/lib/supermassive-ast/directives.d.ts.map +0 -1
- package/lib/supermassive-ast/directives.js +0 -165
- package/lib/supermassive-ast/directives.js.map +0 -7
- package/lib/supermassive-ast/directives.mjs +0 -153
- package/lib/supermassive-ast/directives.mjs.map +0 -7
- package/lib/supermassive-ast/index.d.ts +0 -6
- package/lib/supermassive-ast/index.d.ts.map +0 -1
- package/lib/supermassive-ast/index.js +0 -37
- package/lib/supermassive-ast/index.js.map +0 -7
- package/lib/supermassive-ast/index.mjs +0 -27
- package/lib/supermassive-ast/index.mjs.map +0 -7
|
@@ -40,17 +40,11 @@ var __async = (__this, __arguments, generator) => {
|
|
|
40
40
|
|
|
41
41
|
// src/executeWithoutSchema.ts
|
|
42
42
|
import {
|
|
43
|
-
GraphQLEnumType,
|
|
44
43
|
GraphQLError,
|
|
45
|
-
GraphQLInputObjectType,
|
|
46
|
-
GraphQLScalarType,
|
|
47
|
-
isLeafType,
|
|
48
44
|
Kind,
|
|
49
|
-
locatedError
|
|
50
|
-
} from "graphql";
|
|
51
|
-
import {
|
|
45
|
+
locatedError,
|
|
52
46
|
OperationTypeNode
|
|
53
|
-
} from "
|
|
47
|
+
} from "graphql";
|
|
54
48
|
import {
|
|
55
49
|
collectFields,
|
|
56
50
|
collectSubfields as _collectSubfields
|
|
@@ -64,33 +58,32 @@ import { isPromise } from "./jsutils/isPromise.mjs";
|
|
|
64
58
|
import { addPath, pathToArray } from "./jsutils/Path.mjs";
|
|
65
59
|
import { promiseForObject } from "./jsutils/promiseForObject.mjs";
|
|
66
60
|
import { promiseReduce } from "./jsutils/promiseReduce.mjs";
|
|
67
|
-
import { isUnionResolverType, isInterfaceResolverType } from "./definition.mjs";
|
|
68
|
-
import { mergeResolvers } from "./utilities/mergeResolvers.mjs";
|
|
69
|
-
import { typeNameFromAST } from "./utilities/typeNameFromAST.mjs";
|
|
70
61
|
import {
|
|
71
62
|
getArgumentValues,
|
|
72
63
|
getVariableValues,
|
|
73
|
-
specifiedScalars,
|
|
74
64
|
getDirectiveValues
|
|
75
65
|
} from "./values.mjs";
|
|
76
66
|
import { arraysAreEqual } from "./utilities/array.mjs";
|
|
77
67
|
import { isAsyncIterable } from "./jsutils/isAsyncIterable.mjs";
|
|
78
68
|
import { mapAsyncIterator } from "./utilities/mapAsyncIterator.mjs";
|
|
79
|
-
import { GraphQLStreamDirective } from "./directives.mjs";
|
|
69
|
+
import { GraphQLStreamDirective } from "./schema/directives.mjs";
|
|
80
70
|
import { memoize3 } from "./jsutils/memoize3.mjs";
|
|
71
|
+
import { SchemaFragment } from "./schema/fragment.mjs";
|
|
72
|
+
import {
|
|
73
|
+
inspectTypeReference,
|
|
74
|
+
isListType,
|
|
75
|
+
isNonNullType,
|
|
76
|
+
typeNameFromReference,
|
|
77
|
+
unwrap
|
|
78
|
+
} from "./schema/reference.mjs";
|
|
79
|
+
import { getSchemaFragment } from "./utilities/getSchemaFragment.mjs";
|
|
80
|
+
import { mergeSchemaDefinitions } from "./utilities/mergeDefinitions.mjs";
|
|
81
81
|
var collectSubfields = memoize3(
|
|
82
|
-
(exeContext, returnTypeName, fieldGroup) => _collectSubfields(
|
|
83
|
-
exeContext.resolvers,
|
|
84
|
-
exeContext.fragments,
|
|
85
|
-
exeContext.variableValues,
|
|
86
|
-
exeContext.operation,
|
|
87
|
-
returnTypeName.name,
|
|
88
|
-
fieldGroup
|
|
89
|
-
)
|
|
82
|
+
(exeContext, returnTypeName, fieldGroup) => _collectSubfields(exeContext, returnTypeName.name, fieldGroup)
|
|
90
83
|
);
|
|
91
84
|
function executeWithoutSchema(args) {
|
|
92
85
|
const exeContext = buildExecutionContext(args);
|
|
93
|
-
if (!("
|
|
86
|
+
if (!("schemaTypes" in exeContext)) {
|
|
94
87
|
return { errors: exeContext };
|
|
95
88
|
} else {
|
|
96
89
|
return executeOperation(exeContext);
|
|
@@ -107,7 +100,7 @@ function buildExecutionContext(args) {
|
|
|
107
100
|
var _a, _b;
|
|
108
101
|
const {
|
|
109
102
|
resolvers,
|
|
110
|
-
|
|
103
|
+
schemaFragment: explicitSchemaFragment,
|
|
111
104
|
document,
|
|
112
105
|
rootValue,
|
|
113
106
|
contextValue,
|
|
@@ -120,7 +113,6 @@ function buildExecutionContext(args) {
|
|
|
120
113
|
fieldExecutionHooks
|
|
121
114
|
} = args;
|
|
122
115
|
assertValidExecutionArguments(document, variableValues);
|
|
123
|
-
const combinedResolvers = schemaResolvers ? mergeResolvers(resolvers, schemaResolvers) : resolvers;
|
|
124
116
|
let operation;
|
|
125
117
|
const fragments = /* @__PURE__ */ Object.create(null);
|
|
126
118
|
for (const definition of document.definitions) {
|
|
@@ -150,9 +142,24 @@ function buildExecutionContext(args) {
|
|
|
150
142
|
}
|
|
151
143
|
return [new GraphQLError("Must provide an operation.")];
|
|
152
144
|
}
|
|
145
|
+
let schemaFragment = explicitSchemaFragment;
|
|
146
|
+
if (!schemaFragment) {
|
|
147
|
+
schemaFragment = getSchemaFragment(operation);
|
|
148
|
+
if (schemaFragment && !schemaFragment.__merged) {
|
|
149
|
+
mergeSchemaDefinitions(
|
|
150
|
+
schemaFragment,
|
|
151
|
+
Object.values(fragments).map((fragmentDef) => getSchemaFragment(fragmentDef)).filter((f) => Boolean(f))
|
|
152
|
+
);
|
|
153
|
+
schemaFragment.__merged = true;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (!schemaFragment) {
|
|
157
|
+
return [new GraphQLError("Must provide schema fragment.")];
|
|
158
|
+
}
|
|
153
159
|
const variableDefinitions = (_b = operation.variableDefinitions) != null ? _b : [];
|
|
160
|
+
const schemaTypes = new SchemaFragment(schemaFragment, resolvers);
|
|
154
161
|
const coercedVariableValues = getVariableValues(
|
|
155
|
-
|
|
162
|
+
schemaTypes,
|
|
156
163
|
variableDefinitions,
|
|
157
164
|
variableValues != null ? variableValues : {},
|
|
158
165
|
{ maxErrors: 50 }
|
|
@@ -161,7 +168,7 @@ function buildExecutionContext(args) {
|
|
|
161
168
|
return coercedVariableValues.errors;
|
|
162
169
|
}
|
|
163
170
|
return {
|
|
164
|
-
|
|
171
|
+
schemaTypes,
|
|
165
172
|
fragments,
|
|
166
173
|
rootValue,
|
|
167
174
|
contextValue: buildContextValue ? buildContextValue(contextValue) : contextValue,
|
|
@@ -185,15 +192,9 @@ function buildPerEventExecutionContext(exeContext, payload) {
|
|
|
185
192
|
});
|
|
186
193
|
}
|
|
187
194
|
function executeOperation(exeContext) {
|
|
188
|
-
const { operation, rootValue
|
|
195
|
+
const { operation, rootValue } = exeContext;
|
|
189
196
|
const rootTypeName = getOperationRootTypeName(operation);
|
|
190
|
-
const { groupedFieldSet, patches } = collectFields(
|
|
191
|
-
resolvers,
|
|
192
|
-
fragments,
|
|
193
|
-
variableValues,
|
|
194
|
-
rootTypeName,
|
|
195
|
-
operation
|
|
196
|
-
);
|
|
197
|
+
const { groupedFieldSet, patches } = collectFields(exeContext, rootTypeName);
|
|
197
198
|
const path = void 0;
|
|
198
199
|
let result;
|
|
199
200
|
switch (operation.operation) {
|
|
@@ -323,52 +324,34 @@ function executeFields(exeContext, parentTypeName, sourceValue, path, groupedFie
|
|
|
323
324
|
return promiseForObject(results);
|
|
324
325
|
}
|
|
325
326
|
function executeField(exeContext, parentTypeName, source, fieldGroup, path, incrementalDataRecord) {
|
|
327
|
+
var _a;
|
|
328
|
+
const schemaTypes = exeContext.schemaTypes;
|
|
326
329
|
const fieldName = fieldGroup[0].name.value;
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
if (fieldName === "__typename" && !resolveFn) {
|
|
331
|
-
resolveFn = () => parentTypeName;
|
|
332
|
-
returnTypeName = "String";
|
|
333
|
-
returnTypeNode = {
|
|
334
|
-
kind: Kind.NAMED_TYPE,
|
|
335
|
-
name: {
|
|
336
|
-
kind: Kind.NAME,
|
|
337
|
-
value: "String"
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
} else {
|
|
341
|
-
returnTypeNode = fieldGroup[0].__type;
|
|
342
|
-
returnTypeName = typeNameFromAST(returnTypeNode);
|
|
343
|
-
const typeResolvers = exeContext.resolvers[parentTypeName];
|
|
344
|
-
resolveFn = typeResolvers == null ? void 0 : typeResolvers[fieldName];
|
|
345
|
-
if (typeof resolveFn !== "function" && resolveFn != null) {
|
|
346
|
-
resolveFn = resolveFn.resolve;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
const isDefaultResolverUsed = !resolveFn;
|
|
350
|
-
if (!resolveFn) {
|
|
351
|
-
resolveFn = exeContext.fieldResolver;
|
|
330
|
+
const fieldDef = schemaTypes.getField(parentTypeName, fieldName);
|
|
331
|
+
if (fieldDef === void 0) {
|
|
332
|
+
return;
|
|
352
333
|
}
|
|
334
|
+
const returnTypeRef = schemaTypes.getTypeReference(fieldDef);
|
|
335
|
+
const resolveFn = (_a = schemaTypes.getFieldResolver(parentTypeName, fieldName)) != null ? _a : exeContext.fieldResolver;
|
|
353
336
|
const info = buildResolveInfo(
|
|
354
337
|
exeContext,
|
|
355
338
|
fieldName,
|
|
356
339
|
fieldGroup,
|
|
357
340
|
parentTypeName,
|
|
358
|
-
|
|
359
|
-
returnTypeNode,
|
|
341
|
+
typeNameFromReference(returnTypeRef),
|
|
360
342
|
path
|
|
361
343
|
);
|
|
362
344
|
return resolveAndCompleteField(
|
|
363
345
|
exeContext,
|
|
364
|
-
|
|
346
|
+
parentTypeName,
|
|
347
|
+
returnTypeRef,
|
|
348
|
+
fieldDef,
|
|
365
349
|
fieldGroup,
|
|
366
350
|
info,
|
|
367
351
|
path,
|
|
368
352
|
resolveFn,
|
|
369
353
|
source,
|
|
370
|
-
incrementalDataRecord
|
|
371
|
-
isDefaultResolverUsed
|
|
354
|
+
incrementalDataRecord
|
|
372
355
|
);
|
|
373
356
|
}
|
|
374
357
|
function createSourceEventStream(exeContext) {
|
|
@@ -383,71 +366,43 @@ function createSourceEventStream(exeContext) {
|
|
|
383
366
|
}
|
|
384
367
|
}
|
|
385
368
|
function executeSubscriptionImpl(exeContext) {
|
|
386
|
-
|
|
387
|
-
const
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
fragments,
|
|
391
|
-
variableValues,
|
|
392
|
-
typeName,
|
|
393
|
-
operation
|
|
394
|
-
);
|
|
369
|
+
var _a;
|
|
370
|
+
const { operation, rootValue, schemaTypes } = exeContext;
|
|
371
|
+
const rootTypeName = getOperationRootTypeName(operation);
|
|
372
|
+
const { groupedFieldSet } = collectFields(exeContext, rootTypeName);
|
|
395
373
|
const firstRootField = groupedFieldSet.entries().next().value;
|
|
396
374
|
const [responseName, fieldGroup] = firstRootField;
|
|
397
375
|
const fieldName = fieldGroup[0].name.value;
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
returnTypeNode = {
|
|
405
|
-
kind: Kind.NAMED_TYPE,
|
|
406
|
-
name: {
|
|
407
|
-
kind: Kind.NAME,
|
|
408
|
-
value: "String"
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
|
-
} else {
|
|
412
|
-
returnTypeNode = fieldGroup[0].__type;
|
|
413
|
-
returnTypeName = typeNameFromAST(returnTypeNode);
|
|
414
|
-
const typeResolvers = exeContext.resolvers[typeName];
|
|
415
|
-
const fieldResolver = typeResolvers == null ? void 0 : typeResolvers[fieldName];
|
|
416
|
-
resolveFn = fieldResolver == null ? void 0 : fieldResolver.subscribe;
|
|
417
|
-
}
|
|
418
|
-
if (!resolveFn) {
|
|
419
|
-
resolveFn = exeContext.subscribeFieldResolver;
|
|
376
|
+
const fieldDef = schemaTypes.getField(rootTypeName, fieldName);
|
|
377
|
+
if (!fieldDef) {
|
|
378
|
+
throw new GraphQLError(
|
|
379
|
+
`The subscription field "${fieldName}" is not defined.`,
|
|
380
|
+
{ nodes: fieldGroup }
|
|
381
|
+
);
|
|
420
382
|
}
|
|
421
|
-
const
|
|
383
|
+
const returnTypeRef = schemaTypes.getTypeReference(fieldDef);
|
|
384
|
+
const resolveFn = (_a = schemaTypes.getSubscriptionFieldResolver(rootTypeName, fieldName)) != null ? _a : exeContext.subscribeFieldResolver;
|
|
385
|
+
const path = addPath(void 0, responseName, rootTypeName);
|
|
422
386
|
const info = buildResolveInfo(
|
|
423
387
|
exeContext,
|
|
424
388
|
fieldName,
|
|
425
389
|
fieldGroup,
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
returnTypeNode,
|
|
390
|
+
rootTypeName,
|
|
391
|
+
typeNameFromReference(returnTypeRef),
|
|
429
392
|
path
|
|
430
393
|
);
|
|
431
394
|
try {
|
|
432
|
-
const args = getArgumentValues(
|
|
395
|
+
const args = getArgumentValues(exeContext, fieldDef, fieldGroup[0]);
|
|
433
396
|
const contextValue = exeContext.contextValue;
|
|
434
397
|
const result = resolveFn(rootValue, args, contextValue, info);
|
|
435
398
|
if (isPromise(result)) {
|
|
436
399
|
return result.then(assertEventStream).then(void 0, (error) => {
|
|
437
|
-
throw locatedError(
|
|
438
|
-
error,
|
|
439
|
-
fieldGroup,
|
|
440
|
-
pathToArray(path)
|
|
441
|
-
);
|
|
400
|
+
throw locatedError(error, fieldGroup, pathToArray(path));
|
|
442
401
|
});
|
|
443
402
|
}
|
|
444
403
|
return assertEventStream(result);
|
|
445
404
|
} catch (error) {
|
|
446
|
-
throw locatedError(
|
|
447
|
-
error,
|
|
448
|
-
fieldGroup,
|
|
449
|
-
pathToArray(path)
|
|
450
|
-
);
|
|
405
|
+
throw locatedError(error, fieldGroup, pathToArray(path));
|
|
451
406
|
}
|
|
452
407
|
}
|
|
453
408
|
function assertEventStream(result) {
|
|
@@ -495,13 +450,12 @@ function mapResultOrEventStreamOrPromise(resultOrStreamOrPromise, exeContext, pa
|
|
|
495
450
|
}
|
|
496
451
|
}
|
|
497
452
|
}
|
|
498
|
-
function buildResolveInfo(exeContext, fieldName, fieldGroup, parentTypeName, returnTypeName,
|
|
453
|
+
function buildResolveInfo(exeContext, fieldName, fieldGroup, parentTypeName, returnTypeName, path) {
|
|
499
454
|
return {
|
|
500
455
|
fieldName,
|
|
501
456
|
fieldGroup,
|
|
502
457
|
returnTypeName,
|
|
503
458
|
parentTypeName,
|
|
504
|
-
returnTypeNode,
|
|
505
459
|
path,
|
|
506
460
|
fragments: exeContext.fragments,
|
|
507
461
|
rootValue: exeContext.rootValue,
|
|
@@ -509,27 +463,20 @@ function buildResolveInfo(exeContext, fieldName, fieldGroup, parentTypeName, ret
|
|
|
509
463
|
variableValues: exeContext.variableValues
|
|
510
464
|
};
|
|
511
465
|
}
|
|
512
|
-
function handleFieldError(rawError, exeContext,
|
|
466
|
+
function handleFieldError(rawError, exeContext, returnTypeRef, fieldGroup, path, incrementalDataRecord) {
|
|
513
467
|
var _a;
|
|
514
|
-
const error = locatedError(
|
|
515
|
-
|
|
516
|
-
fieldGroup,
|
|
517
|
-
pathToArray(path)
|
|
518
|
-
);
|
|
519
|
-
if (returnTypeNode.kind === Kind.NON_NULL_TYPE) {
|
|
468
|
+
const error = locatedError(rawError, fieldGroup, pathToArray(path));
|
|
469
|
+
if (isNonNullType(returnTypeRef)) {
|
|
520
470
|
throw error;
|
|
521
471
|
}
|
|
522
472
|
const errors = (_a = incrementalDataRecord == null ? void 0 : incrementalDataRecord.errors) != null ? _a : exeContext.errors;
|
|
523
473
|
errors.push(error);
|
|
524
474
|
}
|
|
525
|
-
function resolveAndCompleteField(exeContext,
|
|
475
|
+
function resolveAndCompleteField(exeContext, parentTypeName, returnTypeRef, fieldDefinition, fieldGroup, info, path, resolveFn, source, incrementalDataRecord) {
|
|
476
|
+
const isDefaultResolverUsed = resolveFn === exeContext.fieldResolver;
|
|
526
477
|
const hooks = exeContext.fieldExecutionHooks;
|
|
527
478
|
try {
|
|
528
|
-
const args = getArgumentValues(
|
|
529
|
-
exeContext.resolvers,
|
|
530
|
-
fieldGroup[0],
|
|
531
|
-
exeContext.variableValues
|
|
532
|
-
);
|
|
479
|
+
const args = getArgumentValues(exeContext, fieldDefinition, fieldGroup[0]);
|
|
533
480
|
const contextValue = exeContext.contextValue;
|
|
534
481
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.beforeFieldResolve)) {
|
|
535
482
|
invokeBeforeFieldResolveHook(info, exeContext);
|
|
@@ -544,7 +491,7 @@ function resolveAndCompleteField(exeContext, returnTypeNode, fieldGroup, info, p
|
|
|
544
491
|
}
|
|
545
492
|
return completeValue(
|
|
546
493
|
exeContext,
|
|
547
|
-
|
|
494
|
+
returnTypeRef,
|
|
548
495
|
fieldGroup,
|
|
549
496
|
info,
|
|
550
497
|
path,
|
|
@@ -565,7 +512,7 @@ function resolveAndCompleteField(exeContext, returnTypeNode, fieldGroup, info, p
|
|
|
565
512
|
}
|
|
566
513
|
completed = completeValue(
|
|
567
514
|
exeContext,
|
|
568
|
-
|
|
515
|
+
returnTypeRef,
|
|
569
516
|
fieldGroup,
|
|
570
517
|
info,
|
|
571
518
|
path,
|
|
@@ -582,18 +529,14 @@ function resolveAndCompleteField(exeContext, returnTypeNode, fieldGroup, info, p
|
|
|
582
529
|
return resolved;
|
|
583
530
|
},
|
|
584
531
|
(rawError) => {
|
|
585
|
-
const error = locatedError(
|
|
586
|
-
rawError,
|
|
587
|
-
fieldGroup,
|
|
588
|
-
pathToArray(path)
|
|
589
|
-
);
|
|
532
|
+
const error = locatedError(rawError, fieldGroup, pathToArray(path));
|
|
590
533
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
591
534
|
invokeAfterFieldCompleteHook(info, exeContext, void 0, error);
|
|
592
535
|
}
|
|
593
536
|
handleFieldError(
|
|
594
537
|
rawError,
|
|
595
538
|
exeContext,
|
|
596
|
-
|
|
539
|
+
returnTypeRef,
|
|
597
540
|
fieldGroup,
|
|
598
541
|
path,
|
|
599
542
|
incrementalDataRecord
|
|
@@ -608,11 +551,7 @@ function resolveAndCompleteField(exeContext, returnTypeNode, fieldGroup, info, p
|
|
|
608
551
|
return completed;
|
|
609
552
|
} catch (rawError) {
|
|
610
553
|
const pathArray = pathToArray(path);
|
|
611
|
-
const error = locatedError(
|
|
612
|
-
rawError,
|
|
613
|
-
fieldGroup,
|
|
614
|
-
pathArray
|
|
615
|
-
);
|
|
554
|
+
const error = locatedError(rawError, fieldGroup, pathArray);
|
|
616
555
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve) && error.path && arraysAreEqual(pathArray, error.path)) {
|
|
617
556
|
invokeAfterFieldResolveHook(info, exeContext, void 0, error);
|
|
618
557
|
}
|
|
@@ -622,7 +561,7 @@ function resolveAndCompleteField(exeContext, returnTypeNode, fieldGroup, info, p
|
|
|
622
561
|
handleFieldError(
|
|
623
562
|
rawError,
|
|
624
563
|
exeContext,
|
|
625
|
-
|
|
564
|
+
returnTypeRef,
|
|
626
565
|
fieldGroup,
|
|
627
566
|
path,
|
|
628
567
|
incrementalDataRecord
|
|
@@ -630,14 +569,14 @@ function resolveAndCompleteField(exeContext, returnTypeNode, fieldGroup, info, p
|
|
|
630
569
|
return null;
|
|
631
570
|
}
|
|
632
571
|
}
|
|
633
|
-
function completeValue(exeContext,
|
|
572
|
+
function completeValue(exeContext, returnTypeRef, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
634
573
|
if (result instanceof Error) {
|
|
635
574
|
throw result;
|
|
636
575
|
}
|
|
637
|
-
if (
|
|
576
|
+
if (isNonNullType(returnTypeRef)) {
|
|
638
577
|
const completed = completeValue(
|
|
639
578
|
exeContext,
|
|
640
|
-
|
|
579
|
+
unwrap(returnTypeRef),
|
|
641
580
|
fieldGroup,
|
|
642
581
|
info,
|
|
643
582
|
path,
|
|
@@ -654,10 +593,10 @@ function completeValue(exeContext, returnTypeNode, fieldGroup, info, path, resul
|
|
|
654
593
|
if (result == null) {
|
|
655
594
|
return null;
|
|
656
595
|
}
|
|
657
|
-
if (
|
|
596
|
+
if (isListType(returnTypeRef)) {
|
|
658
597
|
return completeListValue(
|
|
659
598
|
exeContext,
|
|
660
|
-
|
|
599
|
+
returnTypeRef,
|
|
661
600
|
fieldGroup,
|
|
662
601
|
info,
|
|
663
602
|
path,
|
|
@@ -665,20 +604,16 @@ function completeValue(exeContext, returnTypeNode, fieldGroup, info, path, resul
|
|
|
665
604
|
incrementalDataRecord
|
|
666
605
|
);
|
|
667
606
|
}
|
|
668
|
-
const
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
if (isLeafType(returnType)) {
|
|
674
|
-
return completeLeafValue(returnType, result);
|
|
607
|
+
const schemaTypes = exeContext.schemaTypes;
|
|
608
|
+
const returnTypeName = typeNameFromReference(returnTypeRef);
|
|
609
|
+
const leafType = schemaTypes.getLeafTypeResolver(returnTypeRef);
|
|
610
|
+
if (leafType) {
|
|
611
|
+
return completeLeafValue(leafType, result);
|
|
675
612
|
}
|
|
676
|
-
if (
|
|
677
|
-
}
|
|
678
|
-
if (isUnionResolverType(returnType) || isInterfaceResolverType(returnType)) {
|
|
613
|
+
if (schemaTypes.isAbstractType(returnTypeRef)) {
|
|
679
614
|
return completeAbstractValue(
|
|
680
615
|
exeContext,
|
|
681
|
-
|
|
616
|
+
returnTypeName,
|
|
682
617
|
fieldGroup,
|
|
683
618
|
info,
|
|
684
619
|
path,
|
|
@@ -686,7 +621,7 @@ function completeValue(exeContext, returnTypeNode, fieldGroup, info, path, resul
|
|
|
686
621
|
incrementalDataRecord
|
|
687
622
|
);
|
|
688
623
|
}
|
|
689
|
-
if (
|
|
624
|
+
if (schemaTypes.isObjectType(returnTypeRef)) {
|
|
690
625
|
return completeObjectValue(
|
|
691
626
|
exeContext,
|
|
692
627
|
returnTypeName,
|
|
@@ -698,16 +633,16 @@ function completeValue(exeContext, returnTypeNode, fieldGroup, info, path, resul
|
|
|
698
633
|
}
|
|
699
634
|
invariant(
|
|
700
635
|
false,
|
|
701
|
-
"Cannot complete value of unexpected output type: " +
|
|
636
|
+
"Cannot complete value of unexpected output type: " + inspectTypeReference(returnTypeRef)
|
|
702
637
|
);
|
|
703
638
|
}
|
|
704
|
-
function completePromisedValue(exeContext,
|
|
639
|
+
function completePromisedValue(exeContext, returnTypeRef, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
705
640
|
return __async(this, null, function* () {
|
|
706
641
|
try {
|
|
707
642
|
const resolved = yield result;
|
|
708
643
|
let completed = completeValue(
|
|
709
644
|
exeContext,
|
|
710
|
-
|
|
645
|
+
returnTypeRef,
|
|
711
646
|
fieldGroup,
|
|
712
647
|
info,
|
|
713
648
|
path,
|
|
@@ -722,7 +657,7 @@ function completePromisedValue(exeContext, returnTypeNode, fieldGroup, info, pat
|
|
|
722
657
|
handleFieldError(
|
|
723
658
|
rawError,
|
|
724
659
|
exeContext,
|
|
725
|
-
|
|
660
|
+
returnTypeRef,
|
|
726
661
|
fieldGroup,
|
|
727
662
|
path,
|
|
728
663
|
incrementalDataRecord
|
|
@@ -732,13 +667,13 @@ function completePromisedValue(exeContext, returnTypeNode, fieldGroup, info, pat
|
|
|
732
667
|
}
|
|
733
668
|
});
|
|
734
669
|
}
|
|
735
|
-
function completeListValue(exeContext,
|
|
736
|
-
const
|
|
670
|
+
function completeListValue(exeContext, returnTypeRef, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
671
|
+
const itemTypeRef = unwrap(returnTypeRef);
|
|
737
672
|
if (isAsyncIterable(result)) {
|
|
738
673
|
const asyncIterator = result[Symbol.asyncIterator]();
|
|
739
674
|
return completeAsyncIteratorValue(
|
|
740
675
|
exeContext,
|
|
741
|
-
|
|
676
|
+
itemTypeRef,
|
|
742
677
|
fieldGroup,
|
|
743
678
|
info,
|
|
744
679
|
path,
|
|
@@ -766,7 +701,7 @@ function completeListValue(exeContext, returnTypeNode, fieldGroup, info, path, r
|
|
|
766
701
|
exeContext,
|
|
767
702
|
fieldGroup,
|
|
768
703
|
info,
|
|
769
|
-
|
|
704
|
+
itemTypeRef,
|
|
770
705
|
stream.label,
|
|
771
706
|
previousIncrementalDataRecord
|
|
772
707
|
);
|
|
@@ -777,7 +712,7 @@ function completeListValue(exeContext, returnTypeNode, fieldGroup, info, path, r
|
|
|
777
712
|
item,
|
|
778
713
|
completedResults,
|
|
779
714
|
exeContext,
|
|
780
|
-
|
|
715
|
+
itemTypeRef,
|
|
781
716
|
fieldGroup,
|
|
782
717
|
info,
|
|
783
718
|
itemPath,
|
|
@@ -789,12 +724,12 @@ function completeListValue(exeContext, returnTypeNode, fieldGroup, info, path, r
|
|
|
789
724
|
}
|
|
790
725
|
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
791
726
|
}
|
|
792
|
-
function completeListItemValue(item, completedResults, exeContext,
|
|
727
|
+
function completeListItemValue(item, completedResults, exeContext, itemTypeRef, fieldGroup, info, itemPath, incrementalDataRecord) {
|
|
793
728
|
if (isPromise(item)) {
|
|
794
729
|
completedResults.push(
|
|
795
730
|
completePromisedValue(
|
|
796
731
|
exeContext,
|
|
797
|
-
|
|
732
|
+
itemTypeRef,
|
|
798
733
|
fieldGroup,
|
|
799
734
|
info,
|
|
800
735
|
itemPath,
|
|
@@ -807,7 +742,7 @@ function completeListItemValue(item, completedResults, exeContext, itemTypeNode,
|
|
|
807
742
|
try {
|
|
808
743
|
const completedItem = completeValue(
|
|
809
744
|
exeContext,
|
|
810
|
-
|
|
745
|
+
itemTypeRef,
|
|
811
746
|
fieldGroup,
|
|
812
747
|
info,
|
|
813
748
|
itemPath,
|
|
@@ -820,7 +755,7 @@ function completeListItemValue(item, completedResults, exeContext, itemTypeNode,
|
|
|
820
755
|
handleFieldError(
|
|
821
756
|
rawError,
|
|
822
757
|
exeContext,
|
|
823
|
-
|
|
758
|
+
itemTypeRef,
|
|
824
759
|
fieldGroup,
|
|
825
760
|
itemPath,
|
|
826
761
|
incrementalDataRecord
|
|
@@ -836,7 +771,7 @@ function completeListItemValue(item, completedResults, exeContext, itemTypeNode,
|
|
|
836
771
|
handleFieldError(
|
|
837
772
|
rawError,
|
|
838
773
|
exeContext,
|
|
839
|
-
|
|
774
|
+
itemTypeRef,
|
|
840
775
|
fieldGroup,
|
|
841
776
|
itemPath,
|
|
842
777
|
incrementalDataRecord
|
|
@@ -851,10 +786,9 @@ function getStreamValues(exeContext, fieldGroup, path) {
|
|
|
851
786
|
return;
|
|
852
787
|
}
|
|
853
788
|
const stream = getDirectiveValues(
|
|
789
|
+
exeContext,
|
|
854
790
|
GraphQLStreamDirective,
|
|
855
|
-
fieldGroup[0]
|
|
856
|
-
exeContext.resolvers,
|
|
857
|
-
exeContext.variableValues
|
|
791
|
+
fieldGroup[0]
|
|
858
792
|
);
|
|
859
793
|
if (!stream) {
|
|
860
794
|
return;
|
|
@@ -879,7 +813,7 @@ function getStreamValues(exeContext, fieldGroup, path) {
|
|
|
879
813
|
label: typeof stream.label === "string" ? stream.label : void 0
|
|
880
814
|
};
|
|
881
815
|
}
|
|
882
|
-
function completeAsyncIteratorValue(exeContext,
|
|
816
|
+
function completeAsyncIteratorValue(exeContext, itemTypeRef, fieldGroup, info, path, asyncIterator, incrementalDataRecord) {
|
|
883
817
|
return __async(this, null, function* () {
|
|
884
818
|
const stream = getStreamValues(exeContext, fieldGroup, path);
|
|
885
819
|
let containsPromise = false;
|
|
@@ -893,7 +827,7 @@ function completeAsyncIteratorValue(exeContext, itemType, fieldGroup, info, path
|
|
|
893
827
|
exeContext,
|
|
894
828
|
fieldGroup,
|
|
895
829
|
info,
|
|
896
|
-
|
|
830
|
+
itemTypeRef,
|
|
897
831
|
path,
|
|
898
832
|
stream.label,
|
|
899
833
|
incrementalDataRecord
|
|
@@ -908,17 +842,13 @@ function completeAsyncIteratorValue(exeContext, itemType, fieldGroup, info, path
|
|
|
908
842
|
break;
|
|
909
843
|
}
|
|
910
844
|
} catch (rawError) {
|
|
911
|
-
throw locatedError(
|
|
912
|
-
rawError,
|
|
913
|
-
fieldGroup,
|
|
914
|
-
pathToArray(path)
|
|
915
|
-
);
|
|
845
|
+
throw locatedError(rawError, fieldGroup, pathToArray(path));
|
|
916
846
|
}
|
|
917
847
|
if (completeListItemValue(
|
|
918
848
|
iteration.value,
|
|
919
849
|
completedResults,
|
|
920
850
|
exeContext,
|
|
921
|
-
|
|
851
|
+
itemTypeRef,
|
|
922
852
|
fieldGroup,
|
|
923
853
|
info,
|
|
924
854
|
itemPath,
|
|
@@ -940,16 +870,23 @@ function completeLeafValue(returnType, result) {
|
|
|
940
870
|
}
|
|
941
871
|
return serializedResult;
|
|
942
872
|
}
|
|
943
|
-
function completeAbstractValue(exeContext,
|
|
873
|
+
function completeAbstractValue(exeContext, returnTypeName, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
944
874
|
var _a;
|
|
945
|
-
const resolveTypeFn = (_a =
|
|
875
|
+
const resolveTypeFn = (_a = exeContext.schemaTypes.getAbstractTypeResolver(returnTypeName)) != null ? _a : exeContext.typeResolver;
|
|
946
876
|
const contextValue = exeContext.contextValue;
|
|
947
877
|
const runtimeTypeName = resolveTypeFn(result, contextValue, info);
|
|
948
878
|
if (isPromise(runtimeTypeName)) {
|
|
949
879
|
return runtimeTypeName.then(
|
|
950
880
|
(resolvedRuntimeTypeName) => completeObjectValue(
|
|
951
881
|
exeContext,
|
|
952
|
-
ensureValidRuntimeType(
|
|
882
|
+
ensureValidRuntimeType(
|
|
883
|
+
resolvedRuntimeTypeName,
|
|
884
|
+
exeContext,
|
|
885
|
+
returnTypeName,
|
|
886
|
+
fieldGroup,
|
|
887
|
+
info,
|
|
888
|
+
result
|
|
889
|
+
),
|
|
953
890
|
fieldGroup,
|
|
954
891
|
path,
|
|
955
892
|
result,
|
|
@@ -959,48 +896,63 @@ function completeAbstractValue(exeContext, returnType, fieldGroup, info, path, r
|
|
|
959
896
|
}
|
|
960
897
|
return completeObjectValue(
|
|
961
898
|
exeContext,
|
|
962
|
-
ensureValidRuntimeType(
|
|
899
|
+
ensureValidRuntimeType(
|
|
900
|
+
runtimeTypeName,
|
|
901
|
+
exeContext,
|
|
902
|
+
returnTypeName,
|
|
903
|
+
fieldGroup,
|
|
904
|
+
info,
|
|
905
|
+
result
|
|
906
|
+
),
|
|
963
907
|
fieldGroup,
|
|
964
908
|
path,
|
|
965
909
|
result,
|
|
966
910
|
incrementalDataRecord
|
|
967
911
|
);
|
|
968
912
|
}
|
|
969
|
-
function ensureValidRuntimeType(runtimeTypeName, exeContext) {
|
|
970
|
-
if (
|
|
913
|
+
function ensureValidRuntimeType(runtimeTypeName, exeContext, returnTypeName, fieldGroup, info, result) {
|
|
914
|
+
if (runtimeTypeName == null) {
|
|
971
915
|
throw new GraphQLError(
|
|
972
|
-
`
|
|
916
|
+
`Abstract type "${returnTypeName}" must resolve to an Object type at runtime for field "${info.parentTypeName}.${info.fieldName}". Either the "${returnTypeName}" should provide a "__resolveType" resolver function or "${info.parentTypeName}.${info.fieldName}" should be an object with "__typename" property.`,
|
|
917
|
+
{ nodes: fieldGroup }
|
|
973
918
|
);
|
|
974
919
|
}
|
|
975
|
-
|
|
976
|
-
if (!runtimeType) {
|
|
977
|
-
throw new GraphQLError(
|
|
978
|
-
`Type "${runtimeTypeName}" does not exist inside the schema.`
|
|
979
|
-
);
|
|
980
|
-
} else if (runtimeType instanceof GraphQLScalarType || runtimeType instanceof GraphQLEnumType || runtimeType instanceof GraphQLInputObjectType || runtimeType.__resolveType) {
|
|
920
|
+
if (typeof runtimeTypeName !== "string") {
|
|
981
921
|
throw new GraphQLError(
|
|
982
|
-
`
|
|
983
|
-
runtimeType
|
|
984
|
-
)}" type is not a possible type for "${runtimeTypeName}".`
|
|
922
|
+
`Abstract type "${returnTypeName}" must resolve to an Object type at runtime for field "${info.returnTypeName}.${info.fieldName}" with value ${inspect(result)}, received "${inspect(runtimeTypeName)}".`
|
|
985
923
|
);
|
|
986
|
-
} else {
|
|
987
|
-
return runtimeTypeName;
|
|
988
924
|
}
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
if (
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
} else if ("__implementedBy" in runtimeType) {
|
|
1000
|
-
return "GraphQLInterfaceType";
|
|
925
|
+
const schemaTypes = exeContext.schemaTypes;
|
|
926
|
+
const iface = schemaTypes.getInterfaceType(returnTypeName);
|
|
927
|
+
if (iface) {
|
|
928
|
+
if (schemaTypes.isDefined(runtimeTypeName) && !schemaTypes.isObjectType(runtimeTypeName)) {
|
|
929
|
+
throw new GraphQLError(
|
|
930
|
+
`Abstract type "${returnTypeName}" was resolved to a non-object type "${runtimeTypeName}".`,
|
|
931
|
+
{ nodes: fieldGroup }
|
|
932
|
+
);
|
|
933
|
+
}
|
|
934
|
+
schemaTypes.addInterfaceImplementation(returnTypeName, runtimeTypeName);
|
|
1001
935
|
} else {
|
|
1002
|
-
|
|
936
|
+
if (!schemaTypes.isDefined(runtimeTypeName)) {
|
|
937
|
+
throw new GraphQLError(
|
|
938
|
+
`Abstract type "${returnTypeName}" was resolved to a type "${runtimeTypeName}" that does not exist inside the schema.`,
|
|
939
|
+
{ nodes: fieldGroup }
|
|
940
|
+
);
|
|
941
|
+
}
|
|
942
|
+
if (!schemaTypes.isObjectType(runtimeTypeName)) {
|
|
943
|
+
throw new GraphQLError(
|
|
944
|
+
`Abstract type "${returnTypeName}" was resolved to a non-object type "${runtimeTypeName}".`,
|
|
945
|
+
{ nodes: fieldGroup }
|
|
946
|
+
);
|
|
947
|
+
}
|
|
948
|
+
if (!exeContext.schemaTypes.isSubType(returnTypeName, runtimeTypeName)) {
|
|
949
|
+
throw new GraphQLError(
|
|
950
|
+
`Runtime Object type "${runtimeTypeName}" is not a possible type for "${returnTypeName}".`,
|
|
951
|
+
{ nodes: fieldGroup }
|
|
952
|
+
);
|
|
953
|
+
}
|
|
1003
954
|
}
|
|
955
|
+
return runtimeTypeName;
|
|
1004
956
|
}
|
|
1005
957
|
function completeObjectValue(exeContext, returnTypeName, fieldGroup, path, result, incrementalDataRecord) {
|
|
1006
958
|
return collectAndExecuteSubfields(
|
|
@@ -1182,7 +1134,7 @@ function executeDeferredFragment(exeContext, parentTypeName, sourceValue, fields
|
|
|
1182
1134
|
}
|
|
1183
1135
|
incrementalDataRecord.addData(promiseOrData);
|
|
1184
1136
|
}
|
|
1185
|
-
function executeStreamField(path, itemPath, item, exeContext, fieldGroup, info,
|
|
1137
|
+
function executeStreamField(path, itemPath, item, exeContext, fieldGroup, info, itemTypeRef, label, parentContext) {
|
|
1186
1138
|
const incrementalDataRecord = new StreamItemsRecord({
|
|
1187
1139
|
label,
|
|
1188
1140
|
path: itemPath,
|
|
@@ -1192,7 +1144,7 @@ function executeStreamField(path, itemPath, item, exeContext, fieldGroup, info,
|
|
|
1192
1144
|
if (isPromise(item)) {
|
|
1193
1145
|
const completedItems = completePromisedValue(
|
|
1194
1146
|
exeContext,
|
|
1195
|
-
|
|
1147
|
+
itemTypeRef,
|
|
1196
1148
|
fieldGroup,
|
|
1197
1149
|
info,
|
|
1198
1150
|
itemPath,
|
|
@@ -1214,7 +1166,7 @@ function executeStreamField(path, itemPath, item, exeContext, fieldGroup, info,
|
|
|
1214
1166
|
try {
|
|
1215
1167
|
completedItem = completeValue(
|
|
1216
1168
|
exeContext,
|
|
1217
|
-
|
|
1169
|
+
itemTypeRef,
|
|
1218
1170
|
fieldGroup,
|
|
1219
1171
|
info,
|
|
1220
1172
|
itemPath,
|
|
@@ -1225,7 +1177,7 @@ function executeStreamField(path, itemPath, item, exeContext, fieldGroup, info,
|
|
|
1225
1177
|
handleFieldError(
|
|
1226
1178
|
rawError,
|
|
1227
1179
|
exeContext,
|
|
1228
|
-
|
|
1180
|
+
itemTypeRef,
|
|
1229
1181
|
fieldGroup,
|
|
1230
1182
|
itemPath,
|
|
1231
1183
|
incrementalDataRecord
|
|
@@ -1244,7 +1196,7 @@ function executeStreamField(path, itemPath, item, exeContext, fieldGroup, info,
|
|
|
1244
1196
|
handleFieldError(
|
|
1245
1197
|
rawError,
|
|
1246
1198
|
exeContext,
|
|
1247
|
-
|
|
1199
|
+
itemTypeRef,
|
|
1248
1200
|
fieldGroup,
|
|
1249
1201
|
itemPath,
|
|
1250
1202
|
incrementalDataRecord
|
|
@@ -1265,7 +1217,7 @@ function executeStreamField(path, itemPath, item, exeContext, fieldGroup, info,
|
|
|
1265
1217
|
incrementalDataRecord.addItems([completedItem]);
|
|
1266
1218
|
return incrementalDataRecord;
|
|
1267
1219
|
}
|
|
1268
|
-
function executeStreamAsyncIteratorItem(asyncIterator, exeContext, fieldGroup, info,
|
|
1220
|
+
function executeStreamAsyncIteratorItem(asyncIterator, exeContext, fieldGroup, info, itemTypeRef, incrementalDataRecord, path, itemPath) {
|
|
1269
1221
|
return __async(this, null, function* () {
|
|
1270
1222
|
let item;
|
|
1271
1223
|
try {
|
|
@@ -1276,17 +1228,13 @@ function executeStreamAsyncIteratorItem(asyncIterator, exeContext, fieldGroup, i
|
|
|
1276
1228
|
}
|
|
1277
1229
|
item = value;
|
|
1278
1230
|
} catch (rawError) {
|
|
1279
|
-
throw locatedError(
|
|
1280
|
-
rawError,
|
|
1281
|
-
fieldGroup,
|
|
1282
|
-
pathToArray(path)
|
|
1283
|
-
);
|
|
1231
|
+
throw locatedError(rawError, fieldGroup, pathToArray(path));
|
|
1284
1232
|
}
|
|
1285
1233
|
let completedItem;
|
|
1286
1234
|
try {
|
|
1287
1235
|
completedItem = completeValue(
|
|
1288
1236
|
exeContext,
|
|
1289
|
-
|
|
1237
|
+
itemTypeRef,
|
|
1290
1238
|
fieldGroup,
|
|
1291
1239
|
info,
|
|
1292
1240
|
itemPath,
|
|
@@ -1298,7 +1246,7 @@ function executeStreamAsyncIteratorItem(asyncIterator, exeContext, fieldGroup, i
|
|
|
1298
1246
|
handleFieldError(
|
|
1299
1247
|
rawError,
|
|
1300
1248
|
exeContext,
|
|
1301
|
-
|
|
1249
|
+
itemTypeRef,
|
|
1302
1250
|
fieldGroup,
|
|
1303
1251
|
itemPath,
|
|
1304
1252
|
incrementalDataRecord
|
|
@@ -1312,7 +1260,7 @@ function executeStreamAsyncIteratorItem(asyncIterator, exeContext, fieldGroup, i
|
|
|
1312
1260
|
handleFieldError(
|
|
1313
1261
|
rawError,
|
|
1314
1262
|
exeContext,
|
|
1315
|
-
|
|
1263
|
+
itemTypeRef,
|
|
1316
1264
|
fieldGroup,
|
|
1317
1265
|
itemPath,
|
|
1318
1266
|
incrementalDataRecord
|
|
@@ -1322,7 +1270,7 @@ function executeStreamAsyncIteratorItem(asyncIterator, exeContext, fieldGroup, i
|
|
|
1322
1270
|
}
|
|
1323
1271
|
});
|
|
1324
1272
|
}
|
|
1325
|
-
function executeStreamAsyncIterator(initialIndex, asyncIterator, exeContext, fieldGroup, info,
|
|
1273
|
+
function executeStreamAsyncIterator(initialIndex, asyncIterator, exeContext, fieldGroup, info, itemTypeRef, path, label, parentContext) {
|
|
1326
1274
|
return __async(this, null, function* () {
|
|
1327
1275
|
let index = initialIndex;
|
|
1328
1276
|
let previousIncrementalDataRecord = parentContext != null ? parentContext : void 0;
|
|
@@ -1342,7 +1290,7 @@ function executeStreamAsyncIterator(initialIndex, asyncIterator, exeContext, fie
|
|
|
1342
1290
|
exeContext,
|
|
1343
1291
|
fieldGroup,
|
|
1344
1292
|
info,
|
|
1345
|
-
|
|
1293
|
+
itemTypeRef,
|
|
1346
1294
|
incrementalDataRecord,
|
|
1347
1295
|
path,
|
|
1348
1296
|
itemPath
|