@graphitation/supermassive 3.0.0-alpha.1 → 3.0.0-alpha.4
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/__testUtils__/execute.d.ts +13 -0
- package/lib/__testUtils__/execute.d.ts.map +1 -0
- package/lib/__testUtils__/execute.js +203 -0
- package/lib/__testUtils__/execute.js.map +7 -0
- package/lib/__testUtils__/execute.mjs +181 -0
- package/lib/__testUtils__/execute.mjs.map +7 -0
- package/lib/__testUtils__/gql.d.ts +7 -0
- package/lib/__testUtils__/gql.d.ts.map +1 -0
- package/lib/{supermassive-ast/TypedAST.js → __testUtils__/gql.js} +8 -10
- package/lib/__testUtils__/gql.js.map +7 -0
- package/lib/__testUtils__/gql.mjs +8 -0
- package/lib/__testUtils__/gql.mjs.map +7 -0
- package/lib/benchmarks/index.js +15 -20
- package/lib/benchmarks/index.js.map +3 -3
- package/lib/benchmarks/index.mjs +16 -23
- 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 +27 -17
- package/lib/executeWithSchema.js.map +2 -2
- package/lib/executeWithSchema.mjs +32 -24
- package/lib/executeWithSchema.mjs.map +2 -2
- package/lib/executeWithoutSchema.d.ts +9 -5
- package/lib/executeWithoutSchema.d.ts.map +1 -1
- package/lib/executeWithoutSchema.js +217 -242
- package/lib/executeWithoutSchema.js.map +3 -3
- package/lib/executeWithoutSchema.mjs +225 -249
- package/lib/executeWithoutSchema.mjs.map +3 -3
- package/lib/index.d.ts +16 -11
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +24 -11
- package/lib/index.js.map +2 -2
- package/lib/index.mjs +32 -11
- package/lib/index.mjs.map +2 -2
- package/lib/schema/definition.d.ts +100 -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 +42 -0
- package/lib/schema/directives.d.ts.map +1 -0
- package/lib/schema/directives.js +87 -0
- package/lib/schema/directives.js.map +7 -0
- package/lib/schema/directives.mjs +70 -0
- package/lib/schema/directives.mjs.map +7 -0
- package/lib/schema/fragment.d.ts +63 -0
- package/lib/schema/fragment.d.ts.map +1 -0
- package/lib/schema/fragment.js +295 -0
- package/lib/schema/fragment.js.map +7 -0
- package/lib/schema/fragment.mjs +292 -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 +27 -17
- package/lib/subscribeWithSchema.js.map +2 -2
- package/lib/subscribeWithSchema.mjs +32 -24
- package/lib/subscribeWithSchema.mjs.map +2 -2
- package/lib/types.d.ts +16 -27
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +0 -14
- package/lib/types.js.map +2 -2
- package/lib/types.mjs +0 -11
- package/lib/types.mjs.map +3 -3
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.d.ts +12 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.d.ts.map +1 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.js +116 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.js.map +7 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.mjs +105 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.mjs.map +7 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.d.ts +4 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.d.ts.map +1 -0
- package/lib/{supermassive-ast → utilities}/annotateDocumentGraphQLTransform.js +3 -10
- package/lib/utilities/annotateDocumentGraphQLTransform.js.map +7 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.mjs +10 -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 +246 -0
- package/lib/utilities/decodeASTSchema.js.map +7 -0
- package/lib/utilities/decodeASTSchema.mjs +245 -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 +151 -0
- package/lib/utilities/encodeASTSchema.js.map +7 -0
- package/lib/utilities/encodeASTSchema.mjs +134 -0
- package/lib/utilities/encodeASTSchema.mjs.map +7 -0
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.d.ts +8 -0
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.d.ts.map +1 -0
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.js +238 -0
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.js.map +7 -0
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.mjs +245 -0
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.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/mergeResolvers.d.ts +2 -2
- package/lib/utilities/mergeResolvers.d.ts.map +1 -1
- package/lib/utilities/mergeResolvers.js +20 -22
- package/lib/utilities/mergeResolvers.js.map +2 -2
- package/lib/utilities/mergeResolvers.mjs +20 -25
- package/lib/utilities/mergeResolvers.mjs.map +2 -2
- package/lib/utilities/mergeSchemaDefinitions.d.ts +8 -0
- package/lib/utilities/mergeSchemaDefinitions.d.ts.map +1 -0
- package/lib/utilities/mergeSchemaDefinitions.js +126 -0
- package/lib/utilities/mergeSchemaDefinitions.js.map +7 -0
- package/lib/utilities/mergeSchemaDefinitions.mjs +114 -0
- package/lib/utilities/mergeSchemaDefinitions.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.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 +0 -3
- 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,10 @@ 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
45
|
locatedError
|
|
50
46
|
} from "graphql";
|
|
51
|
-
import {
|
|
52
|
-
OperationTypeNode
|
|
53
|
-
} from "./supermassive-ast/index.mjs";
|
|
54
47
|
import {
|
|
55
48
|
collectFields,
|
|
56
49
|
collectSubfields as _collectSubfields
|
|
@@ -64,33 +57,32 @@ import { isPromise } from "./jsutils/isPromise.mjs";
|
|
|
64
57
|
import { addPath, pathToArray } from "./jsutils/Path.mjs";
|
|
65
58
|
import { promiseForObject } from "./jsutils/promiseForObject.mjs";
|
|
66
59
|
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
60
|
import {
|
|
71
61
|
getArgumentValues,
|
|
72
62
|
getVariableValues,
|
|
73
|
-
specifiedScalars,
|
|
74
63
|
getDirectiveValues
|
|
75
64
|
} from "./values.mjs";
|
|
76
65
|
import { arraysAreEqual } from "./utilities/array.mjs";
|
|
77
66
|
import { isAsyncIterable } from "./jsutils/isAsyncIterable.mjs";
|
|
78
67
|
import { mapAsyncIterator } from "./utilities/mapAsyncIterator.mjs";
|
|
79
|
-
import { GraphQLStreamDirective } from "./directives.mjs";
|
|
68
|
+
import { GraphQLStreamDirective } from "./schema/directives.mjs";
|
|
80
69
|
import { memoize3 } from "./jsutils/memoize3.mjs";
|
|
70
|
+
import {
|
|
71
|
+
PartialSchema
|
|
72
|
+
} from "./schema/fragment.mjs";
|
|
73
|
+
import {
|
|
74
|
+
inspectTypeReference,
|
|
75
|
+
isListType,
|
|
76
|
+
isNonNullType,
|
|
77
|
+
typeNameFromReference,
|
|
78
|
+
unwrap
|
|
79
|
+
} from "./schema/reference.mjs";
|
|
81
80
|
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
|
-
)
|
|
81
|
+
(exeContext, returnTypeName, fieldGroup) => _collectSubfields(exeContext, returnTypeName.name, fieldGroup)
|
|
90
82
|
);
|
|
91
83
|
function executeWithoutSchema(args) {
|
|
92
84
|
const exeContext = buildExecutionContext(args);
|
|
93
|
-
if (!("
|
|
85
|
+
if (!("partialSchema" in exeContext)) {
|
|
94
86
|
return { errors: exeContext };
|
|
95
87
|
} else {
|
|
96
88
|
return executeOperation(exeContext);
|
|
@@ -106,8 +98,9 @@ function assertValidExecutionArguments(document, rawVariableValues) {
|
|
|
106
98
|
function buildExecutionContext(args) {
|
|
107
99
|
var _a, _b;
|
|
108
100
|
const {
|
|
109
|
-
resolvers,
|
|
110
|
-
|
|
101
|
+
// resolvers,
|
|
102
|
+
schemaFragment,
|
|
103
|
+
schemaFragmentLoader,
|
|
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) {
|
|
@@ -151,8 +143,9 @@ function buildExecutionContext(args) {
|
|
|
151
143
|
return [new GraphQLError("Must provide an operation.")];
|
|
152
144
|
}
|
|
153
145
|
const variableDefinitions = (_b = operation.variableDefinitions) != null ? _b : [];
|
|
146
|
+
const partialSchema = new PartialSchema(schemaFragment);
|
|
154
147
|
const coercedVariableValues = getVariableValues(
|
|
155
|
-
|
|
148
|
+
partialSchema,
|
|
156
149
|
variableDefinitions,
|
|
157
150
|
variableValues != null ? variableValues : {},
|
|
158
151
|
{ maxErrors: 50 }
|
|
@@ -161,7 +154,9 @@ function buildExecutionContext(args) {
|
|
|
161
154
|
return coercedVariableValues.errors;
|
|
162
155
|
}
|
|
163
156
|
return {
|
|
164
|
-
|
|
157
|
+
partialSchema,
|
|
158
|
+
schemaFragment,
|
|
159
|
+
schemaFragmentLoader,
|
|
165
160
|
fragments,
|
|
166
161
|
rootValue,
|
|
167
162
|
contextValue: buildContextValue ? buildContextValue(contextValue) : contextValue,
|
|
@@ -185,19 +180,13 @@ function buildPerEventExecutionContext(exeContext, payload) {
|
|
|
185
180
|
});
|
|
186
181
|
}
|
|
187
182
|
function executeOperation(exeContext) {
|
|
188
|
-
const { operation, rootValue
|
|
183
|
+
const { operation, rootValue } = exeContext;
|
|
189
184
|
const rootTypeName = getOperationRootTypeName(operation);
|
|
190
|
-
const { groupedFieldSet, patches } = collectFields(
|
|
191
|
-
resolvers,
|
|
192
|
-
fragments,
|
|
193
|
-
variableValues,
|
|
194
|
-
rootTypeName,
|
|
195
|
-
operation
|
|
196
|
-
);
|
|
185
|
+
const { groupedFieldSet, patches } = collectFields(exeContext, rootTypeName);
|
|
197
186
|
const path = void 0;
|
|
198
187
|
let result;
|
|
199
188
|
switch (operation.operation) {
|
|
200
|
-
case
|
|
189
|
+
case "query":
|
|
201
190
|
result = executeFields(
|
|
202
191
|
exeContext,
|
|
203
192
|
rootTypeName,
|
|
@@ -208,7 +197,7 @@ function executeOperation(exeContext) {
|
|
|
208
197
|
);
|
|
209
198
|
result = buildResponse(exeContext, result);
|
|
210
199
|
break;
|
|
211
|
-
case
|
|
200
|
+
case "mutation":
|
|
212
201
|
result = executeFieldsSerially(
|
|
213
202
|
exeContext,
|
|
214
203
|
rootTypeName,
|
|
@@ -218,7 +207,7 @@ function executeOperation(exeContext) {
|
|
|
218
207
|
);
|
|
219
208
|
result = buildResponse(exeContext, result);
|
|
220
209
|
break;
|
|
221
|
-
case
|
|
210
|
+
case "subscription": {
|
|
222
211
|
const resultOrStreamOrPromise = createSourceEventStream(exeContext);
|
|
223
212
|
result = mapResultOrEventStreamOrPromise(
|
|
224
213
|
resultOrStreamOrPromise,
|
|
@@ -227,7 +216,13 @@ function executeOperation(exeContext) {
|
|
|
227
216
|
path,
|
|
228
217
|
groupedFieldSet
|
|
229
218
|
);
|
|
219
|
+
break;
|
|
230
220
|
}
|
|
221
|
+
default:
|
|
222
|
+
invariant(
|
|
223
|
+
false,
|
|
224
|
+
`Operation "${operation.operation}" is not a part of GraphQL spec`
|
|
225
|
+
);
|
|
231
226
|
}
|
|
232
227
|
for (const patch of patches) {
|
|
233
228
|
const { label, groupedFieldSet: patchGroupedFieldSet } = patch;
|
|
@@ -324,52 +319,43 @@ function executeFields(exeContext, parentTypeName, sourceValue, path, groupedFie
|
|
|
324
319
|
}
|
|
325
320
|
function executeField(exeContext, parentTypeName, source, fieldGroup, path, incrementalDataRecord) {
|
|
326
321
|
const fieldName = fieldGroup[0].name.value;
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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
|
-
}
|
|
322
|
+
const fieldDef = exeContext.partialSchema.getField(parentTypeName, fieldName);
|
|
323
|
+
if (fieldDef !== void 0) {
|
|
324
|
+
return resolveAndCompleteField(
|
|
325
|
+
exeContext,
|
|
326
|
+
parentTypeName,
|
|
327
|
+
fieldDef,
|
|
328
|
+
fieldGroup,
|
|
329
|
+
path,
|
|
330
|
+
source,
|
|
331
|
+
incrementalDataRecord
|
|
332
|
+
);
|
|
348
333
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
resolveFn = exeContext.fieldResolver;
|
|
334
|
+
if (!exeContext.schemaFragmentLoader) {
|
|
335
|
+
return void 0;
|
|
352
336
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
fieldName,
|
|
356
|
-
fieldGroup,
|
|
337
|
+
return exeContext.schemaFragmentLoader(exeContext.schemaFragment, exeContext.contextValue, {
|
|
338
|
+
kind: "byField",
|
|
357
339
|
parentTypeName,
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
exeContext
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
340
|
+
fieldName
|
|
341
|
+
}).then(({ mergedFragment, mergedContextValue }) => {
|
|
342
|
+
exeContext.contextValue = mergedContextValue != null ? mergedContextValue : exeContext.contextValue;
|
|
343
|
+
exeContext.schemaFragment = mergedFragment;
|
|
344
|
+
exeContext.partialSchema.updateSchemaFragment(mergedFragment);
|
|
345
|
+
const fieldDef2 = exeContext.partialSchema.getField(
|
|
346
|
+
parentTypeName,
|
|
347
|
+
fieldName
|
|
348
|
+
);
|
|
349
|
+
return fieldDef2 !== void 0 ? resolveAndCompleteField(
|
|
350
|
+
exeContext,
|
|
351
|
+
parentTypeName,
|
|
352
|
+
fieldDef2,
|
|
353
|
+
fieldGroup,
|
|
354
|
+
path,
|
|
355
|
+
source,
|
|
356
|
+
incrementalDataRecord
|
|
357
|
+
) : void 0;
|
|
358
|
+
});
|
|
373
359
|
}
|
|
374
360
|
function createSourceEventStream(exeContext) {
|
|
375
361
|
try {
|
|
@@ -383,71 +369,43 @@ function createSourceEventStream(exeContext) {
|
|
|
383
369
|
}
|
|
384
370
|
}
|
|
385
371
|
function executeSubscriptionImpl(exeContext) {
|
|
386
|
-
|
|
387
|
-
const
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
fragments,
|
|
391
|
-
variableValues,
|
|
392
|
-
typeName,
|
|
393
|
-
operation
|
|
394
|
-
);
|
|
372
|
+
var _a;
|
|
373
|
+
const { operation, rootValue, partialSchema } = exeContext;
|
|
374
|
+
const rootTypeName = getOperationRootTypeName(operation);
|
|
375
|
+
const { groupedFieldSet } = collectFields(exeContext, rootTypeName);
|
|
395
376
|
const firstRootField = groupedFieldSet.entries().next().value;
|
|
396
377
|
const [responseName, fieldGroup] = firstRootField;
|
|
397
378
|
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;
|
|
379
|
+
const fieldDef = partialSchema.getField(rootTypeName, fieldName);
|
|
380
|
+
if (!fieldDef) {
|
|
381
|
+
throw new GraphQLError(
|
|
382
|
+
`The subscription field "${fieldName}" is not defined.`,
|
|
383
|
+
{ nodes: fieldGroup }
|
|
384
|
+
);
|
|
420
385
|
}
|
|
421
|
-
const
|
|
386
|
+
const returnTypeRef = partialSchema.getTypeReference(fieldDef);
|
|
387
|
+
const resolveFn = (_a = partialSchema.getSubscriptionFieldResolver(rootTypeName, fieldName)) != null ? _a : exeContext.subscribeFieldResolver;
|
|
388
|
+
const path = addPath(void 0, responseName, rootTypeName);
|
|
422
389
|
const info = buildResolveInfo(
|
|
423
390
|
exeContext,
|
|
424
391
|
fieldName,
|
|
425
392
|
fieldGroup,
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
returnTypeNode,
|
|
393
|
+
rootTypeName,
|
|
394
|
+
typeNameFromReference(returnTypeRef),
|
|
429
395
|
path
|
|
430
396
|
);
|
|
431
397
|
try {
|
|
432
|
-
const args = getArgumentValues(
|
|
398
|
+
const args = getArgumentValues(exeContext, fieldDef, fieldGroup[0]);
|
|
433
399
|
const contextValue = exeContext.contextValue;
|
|
434
400
|
const result = resolveFn(rootValue, args, contextValue, info);
|
|
435
401
|
if (isPromise(result)) {
|
|
436
402
|
return result.then(assertEventStream).then(void 0, (error) => {
|
|
437
|
-
throw locatedError(
|
|
438
|
-
error,
|
|
439
|
-
fieldGroup,
|
|
440
|
-
pathToArray(path)
|
|
441
|
-
);
|
|
403
|
+
throw locatedError(error, fieldGroup, pathToArray(path));
|
|
442
404
|
});
|
|
443
405
|
}
|
|
444
406
|
return assertEventStream(result);
|
|
445
407
|
} catch (error) {
|
|
446
|
-
throw locatedError(
|
|
447
|
-
error,
|
|
448
|
-
fieldGroup,
|
|
449
|
-
pathToArray(path)
|
|
450
|
-
);
|
|
408
|
+
throw locatedError(error, fieldGroup, pathToArray(path));
|
|
451
409
|
}
|
|
452
410
|
}
|
|
453
411
|
function assertEventStream(result) {
|
|
@@ -495,13 +453,12 @@ function mapResultOrEventStreamOrPromise(resultOrStreamOrPromise, exeContext, pa
|
|
|
495
453
|
}
|
|
496
454
|
}
|
|
497
455
|
}
|
|
498
|
-
function buildResolveInfo(exeContext, fieldName, fieldGroup, parentTypeName, returnTypeName,
|
|
456
|
+
function buildResolveInfo(exeContext, fieldName, fieldGroup, parentTypeName, returnTypeName, path) {
|
|
499
457
|
return {
|
|
500
458
|
fieldName,
|
|
501
459
|
fieldGroup,
|
|
502
460
|
returnTypeName,
|
|
503
461
|
parentTypeName,
|
|
504
|
-
returnTypeNode,
|
|
505
462
|
path,
|
|
506
463
|
fragments: exeContext.fragments,
|
|
507
464
|
rootValue: exeContext.rootValue,
|
|
@@ -509,27 +466,32 @@ function buildResolveInfo(exeContext, fieldName, fieldGroup, parentTypeName, ret
|
|
|
509
466
|
variableValues: exeContext.variableValues
|
|
510
467
|
};
|
|
511
468
|
}
|
|
512
|
-
function handleFieldError(rawError, exeContext,
|
|
469
|
+
function handleFieldError(rawError, exeContext, returnTypeRef, fieldGroup, path, incrementalDataRecord) {
|
|
513
470
|
var _a;
|
|
514
|
-
const error = locatedError(
|
|
515
|
-
|
|
516
|
-
fieldGroup,
|
|
517
|
-
pathToArray(path)
|
|
518
|
-
);
|
|
519
|
-
if (returnTypeNode.kind === Kind.NON_NULL_TYPE) {
|
|
471
|
+
const error = locatedError(rawError, fieldGroup, pathToArray(path));
|
|
472
|
+
if (isNonNullType(returnTypeRef)) {
|
|
520
473
|
throw error;
|
|
521
474
|
}
|
|
522
475
|
const errors = (_a = incrementalDataRecord == null ? void 0 : incrementalDataRecord.errors) != null ? _a : exeContext.errors;
|
|
523
476
|
errors.push(error);
|
|
524
477
|
}
|
|
525
|
-
function resolveAndCompleteField(exeContext,
|
|
478
|
+
function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fieldGroup, path, source, incrementalDataRecord) {
|
|
479
|
+
var _a;
|
|
480
|
+
const fieldName = fieldGroup[0].name.value;
|
|
481
|
+
const returnTypeRef = exeContext.partialSchema.getTypeReference(fieldDefinition);
|
|
482
|
+
const resolveFn = (_a = exeContext.partialSchema.getFieldResolver(parentTypeName, fieldName)) != null ? _a : exeContext.fieldResolver;
|
|
483
|
+
const info = buildResolveInfo(
|
|
484
|
+
exeContext,
|
|
485
|
+
fieldName,
|
|
486
|
+
fieldGroup,
|
|
487
|
+
parentTypeName,
|
|
488
|
+
typeNameFromReference(returnTypeRef),
|
|
489
|
+
path
|
|
490
|
+
);
|
|
491
|
+
const isDefaultResolverUsed = resolveFn === exeContext.fieldResolver;
|
|
526
492
|
const hooks = exeContext.fieldExecutionHooks;
|
|
527
493
|
try {
|
|
528
|
-
const args = getArgumentValues(
|
|
529
|
-
exeContext.resolvers,
|
|
530
|
-
fieldGroup[0],
|
|
531
|
-
exeContext.variableValues
|
|
532
|
-
);
|
|
494
|
+
const args = getArgumentValues(exeContext, fieldDefinition, fieldGroup[0]);
|
|
533
495
|
const contextValue = exeContext.contextValue;
|
|
534
496
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.beforeFieldResolve)) {
|
|
535
497
|
invokeBeforeFieldResolveHook(info, exeContext);
|
|
@@ -544,7 +506,7 @@ function resolveAndCompleteField(exeContext, returnTypeNode, fieldGroup, info, p
|
|
|
544
506
|
}
|
|
545
507
|
return completeValue(
|
|
546
508
|
exeContext,
|
|
547
|
-
|
|
509
|
+
returnTypeRef,
|
|
548
510
|
fieldGroup,
|
|
549
511
|
info,
|
|
550
512
|
path,
|
|
@@ -565,7 +527,7 @@ function resolveAndCompleteField(exeContext, returnTypeNode, fieldGroup, info, p
|
|
|
565
527
|
}
|
|
566
528
|
completed = completeValue(
|
|
567
529
|
exeContext,
|
|
568
|
-
|
|
530
|
+
returnTypeRef,
|
|
569
531
|
fieldGroup,
|
|
570
532
|
info,
|
|
571
533
|
path,
|
|
@@ -582,18 +544,14 @@ function resolveAndCompleteField(exeContext, returnTypeNode, fieldGroup, info, p
|
|
|
582
544
|
return resolved;
|
|
583
545
|
},
|
|
584
546
|
(rawError) => {
|
|
585
|
-
const error = locatedError(
|
|
586
|
-
rawError,
|
|
587
|
-
fieldGroup,
|
|
588
|
-
pathToArray(path)
|
|
589
|
-
);
|
|
547
|
+
const error = locatedError(rawError, fieldGroup, pathToArray(path));
|
|
590
548
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
591
549
|
invokeAfterFieldCompleteHook(info, exeContext, void 0, error);
|
|
592
550
|
}
|
|
593
551
|
handleFieldError(
|
|
594
552
|
rawError,
|
|
595
553
|
exeContext,
|
|
596
|
-
|
|
554
|
+
returnTypeRef,
|
|
597
555
|
fieldGroup,
|
|
598
556
|
path,
|
|
599
557
|
incrementalDataRecord
|
|
@@ -608,11 +566,7 @@ function resolveAndCompleteField(exeContext, returnTypeNode, fieldGroup, info, p
|
|
|
608
566
|
return completed;
|
|
609
567
|
} catch (rawError) {
|
|
610
568
|
const pathArray = pathToArray(path);
|
|
611
|
-
const error = locatedError(
|
|
612
|
-
rawError,
|
|
613
|
-
fieldGroup,
|
|
614
|
-
pathArray
|
|
615
|
-
);
|
|
569
|
+
const error = locatedError(rawError, fieldGroup, pathArray);
|
|
616
570
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve) && error.path && arraysAreEqual(pathArray, error.path)) {
|
|
617
571
|
invokeAfterFieldResolveHook(info, exeContext, void 0, error);
|
|
618
572
|
}
|
|
@@ -622,7 +576,7 @@ function resolveAndCompleteField(exeContext, returnTypeNode, fieldGroup, info, p
|
|
|
622
576
|
handleFieldError(
|
|
623
577
|
rawError,
|
|
624
578
|
exeContext,
|
|
625
|
-
|
|
579
|
+
returnTypeRef,
|
|
626
580
|
fieldGroup,
|
|
627
581
|
path,
|
|
628
582
|
incrementalDataRecord
|
|
@@ -630,14 +584,14 @@ function resolveAndCompleteField(exeContext, returnTypeNode, fieldGroup, info, p
|
|
|
630
584
|
return null;
|
|
631
585
|
}
|
|
632
586
|
}
|
|
633
|
-
function completeValue(exeContext,
|
|
587
|
+
function completeValue(exeContext, returnTypeRef, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
634
588
|
if (result instanceof Error) {
|
|
635
589
|
throw result;
|
|
636
590
|
}
|
|
637
|
-
if (
|
|
591
|
+
if (isNonNullType(returnTypeRef)) {
|
|
638
592
|
const completed = completeValue(
|
|
639
593
|
exeContext,
|
|
640
|
-
|
|
594
|
+
unwrap(returnTypeRef),
|
|
641
595
|
fieldGroup,
|
|
642
596
|
info,
|
|
643
597
|
path,
|
|
@@ -654,10 +608,10 @@ function completeValue(exeContext, returnTypeNode, fieldGroup, info, path, resul
|
|
|
654
608
|
if (result == null) {
|
|
655
609
|
return null;
|
|
656
610
|
}
|
|
657
|
-
if (
|
|
611
|
+
if (isListType(returnTypeRef)) {
|
|
658
612
|
return completeListValue(
|
|
659
613
|
exeContext,
|
|
660
|
-
|
|
614
|
+
returnTypeRef,
|
|
661
615
|
fieldGroup,
|
|
662
616
|
info,
|
|
663
617
|
path,
|
|
@@ -665,20 +619,16 @@ function completeValue(exeContext, returnTypeNode, fieldGroup, info, path, resul
|
|
|
665
619
|
incrementalDataRecord
|
|
666
620
|
);
|
|
667
621
|
}
|
|
668
|
-
const
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
if (isLeafType(returnType)) {
|
|
674
|
-
return completeLeafValue(returnType, result);
|
|
675
|
-
}
|
|
676
|
-
if (returnType instanceof GraphQLInputObjectType) {
|
|
622
|
+
const partialSchema = exeContext.partialSchema;
|
|
623
|
+
const returnTypeName = typeNameFromReference(returnTypeRef);
|
|
624
|
+
const leafType = partialSchema.getLeafTypeResolver(returnTypeRef);
|
|
625
|
+
if (leafType) {
|
|
626
|
+
return completeLeafValue(leafType, result);
|
|
677
627
|
}
|
|
678
|
-
if (
|
|
628
|
+
if (partialSchema.isAbstractType(returnTypeRef)) {
|
|
679
629
|
return completeAbstractValue(
|
|
680
630
|
exeContext,
|
|
681
|
-
|
|
631
|
+
returnTypeName,
|
|
682
632
|
fieldGroup,
|
|
683
633
|
info,
|
|
684
634
|
path,
|
|
@@ -686,7 +636,7 @@ function completeValue(exeContext, returnTypeNode, fieldGroup, info, path, resul
|
|
|
686
636
|
incrementalDataRecord
|
|
687
637
|
);
|
|
688
638
|
}
|
|
689
|
-
if (
|
|
639
|
+
if (partialSchema.isObjectType(returnTypeRef)) {
|
|
690
640
|
return completeObjectValue(
|
|
691
641
|
exeContext,
|
|
692
642
|
returnTypeName,
|
|
@@ -698,16 +648,16 @@ function completeValue(exeContext, returnTypeNode, fieldGroup, info, path, resul
|
|
|
698
648
|
}
|
|
699
649
|
invariant(
|
|
700
650
|
false,
|
|
701
|
-
"Cannot complete value of unexpected output type: " +
|
|
651
|
+
"Cannot complete value of unexpected output type: " + inspectTypeReference(returnTypeRef)
|
|
702
652
|
);
|
|
703
653
|
}
|
|
704
|
-
function completePromisedValue(exeContext,
|
|
654
|
+
function completePromisedValue(exeContext, returnTypeRef, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
705
655
|
return __async(this, null, function* () {
|
|
706
656
|
try {
|
|
707
657
|
const resolved = yield result;
|
|
708
658
|
let completed = completeValue(
|
|
709
659
|
exeContext,
|
|
710
|
-
|
|
660
|
+
returnTypeRef,
|
|
711
661
|
fieldGroup,
|
|
712
662
|
info,
|
|
713
663
|
path,
|
|
@@ -722,7 +672,7 @@ function completePromisedValue(exeContext, returnTypeNode, fieldGroup, info, pat
|
|
|
722
672
|
handleFieldError(
|
|
723
673
|
rawError,
|
|
724
674
|
exeContext,
|
|
725
|
-
|
|
675
|
+
returnTypeRef,
|
|
726
676
|
fieldGroup,
|
|
727
677
|
path,
|
|
728
678
|
incrementalDataRecord
|
|
@@ -732,13 +682,13 @@ function completePromisedValue(exeContext, returnTypeNode, fieldGroup, info, pat
|
|
|
732
682
|
}
|
|
733
683
|
});
|
|
734
684
|
}
|
|
735
|
-
function completeListValue(exeContext,
|
|
736
|
-
const
|
|
685
|
+
function completeListValue(exeContext, returnTypeRef, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
686
|
+
const itemTypeRef = unwrap(returnTypeRef);
|
|
737
687
|
if (isAsyncIterable(result)) {
|
|
738
688
|
const asyncIterator = result[Symbol.asyncIterator]();
|
|
739
689
|
return completeAsyncIteratorValue(
|
|
740
690
|
exeContext,
|
|
741
|
-
|
|
691
|
+
itemTypeRef,
|
|
742
692
|
fieldGroup,
|
|
743
693
|
info,
|
|
744
694
|
path,
|
|
@@ -766,7 +716,7 @@ function completeListValue(exeContext, returnTypeNode, fieldGroup, info, path, r
|
|
|
766
716
|
exeContext,
|
|
767
717
|
fieldGroup,
|
|
768
718
|
info,
|
|
769
|
-
|
|
719
|
+
itemTypeRef,
|
|
770
720
|
stream.label,
|
|
771
721
|
previousIncrementalDataRecord
|
|
772
722
|
);
|
|
@@ -777,7 +727,7 @@ function completeListValue(exeContext, returnTypeNode, fieldGroup, info, path, r
|
|
|
777
727
|
item,
|
|
778
728
|
completedResults,
|
|
779
729
|
exeContext,
|
|
780
|
-
|
|
730
|
+
itemTypeRef,
|
|
781
731
|
fieldGroup,
|
|
782
732
|
info,
|
|
783
733
|
itemPath,
|
|
@@ -789,12 +739,12 @@ function completeListValue(exeContext, returnTypeNode, fieldGroup, info, path, r
|
|
|
789
739
|
}
|
|
790
740
|
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
791
741
|
}
|
|
792
|
-
function completeListItemValue(item, completedResults, exeContext,
|
|
742
|
+
function completeListItemValue(item, completedResults, exeContext, itemTypeRef, fieldGroup, info, itemPath, incrementalDataRecord) {
|
|
793
743
|
if (isPromise(item)) {
|
|
794
744
|
completedResults.push(
|
|
795
745
|
completePromisedValue(
|
|
796
746
|
exeContext,
|
|
797
|
-
|
|
747
|
+
itemTypeRef,
|
|
798
748
|
fieldGroup,
|
|
799
749
|
info,
|
|
800
750
|
itemPath,
|
|
@@ -807,7 +757,7 @@ function completeListItemValue(item, completedResults, exeContext, itemTypeNode,
|
|
|
807
757
|
try {
|
|
808
758
|
const completedItem = completeValue(
|
|
809
759
|
exeContext,
|
|
810
|
-
|
|
760
|
+
itemTypeRef,
|
|
811
761
|
fieldGroup,
|
|
812
762
|
info,
|
|
813
763
|
itemPath,
|
|
@@ -820,7 +770,7 @@ function completeListItemValue(item, completedResults, exeContext, itemTypeNode,
|
|
|
820
770
|
handleFieldError(
|
|
821
771
|
rawError,
|
|
822
772
|
exeContext,
|
|
823
|
-
|
|
773
|
+
itemTypeRef,
|
|
824
774
|
fieldGroup,
|
|
825
775
|
itemPath,
|
|
826
776
|
incrementalDataRecord
|
|
@@ -836,7 +786,7 @@ function completeListItemValue(item, completedResults, exeContext, itemTypeNode,
|
|
|
836
786
|
handleFieldError(
|
|
837
787
|
rawError,
|
|
838
788
|
exeContext,
|
|
839
|
-
|
|
789
|
+
itemTypeRef,
|
|
840
790
|
fieldGroup,
|
|
841
791
|
itemPath,
|
|
842
792
|
incrementalDataRecord
|
|
@@ -851,10 +801,9 @@ function getStreamValues(exeContext, fieldGroup, path) {
|
|
|
851
801
|
return;
|
|
852
802
|
}
|
|
853
803
|
const stream = getDirectiveValues(
|
|
804
|
+
exeContext,
|
|
854
805
|
GraphQLStreamDirective,
|
|
855
|
-
fieldGroup[0]
|
|
856
|
-
exeContext.resolvers,
|
|
857
|
-
exeContext.variableValues
|
|
806
|
+
fieldGroup[0]
|
|
858
807
|
);
|
|
859
808
|
if (!stream) {
|
|
860
809
|
return;
|
|
@@ -871,7 +820,7 @@ function getStreamValues(exeContext, fieldGroup, path) {
|
|
|
871
820
|
"initialCount must be a positive integer"
|
|
872
821
|
);
|
|
873
822
|
invariant(
|
|
874
|
-
exeContext.operation.operation !==
|
|
823
|
+
exeContext.operation.operation !== "subscription",
|
|
875
824
|
"`@stream` directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`."
|
|
876
825
|
);
|
|
877
826
|
return {
|
|
@@ -879,7 +828,7 @@ function getStreamValues(exeContext, fieldGroup, path) {
|
|
|
879
828
|
label: typeof stream.label === "string" ? stream.label : void 0
|
|
880
829
|
};
|
|
881
830
|
}
|
|
882
|
-
function completeAsyncIteratorValue(exeContext,
|
|
831
|
+
function completeAsyncIteratorValue(exeContext, itemTypeRef, fieldGroup, info, path, asyncIterator, incrementalDataRecord) {
|
|
883
832
|
return __async(this, null, function* () {
|
|
884
833
|
const stream = getStreamValues(exeContext, fieldGroup, path);
|
|
885
834
|
let containsPromise = false;
|
|
@@ -893,7 +842,7 @@ function completeAsyncIteratorValue(exeContext, itemType, fieldGroup, info, path
|
|
|
893
842
|
exeContext,
|
|
894
843
|
fieldGroup,
|
|
895
844
|
info,
|
|
896
|
-
|
|
845
|
+
itemTypeRef,
|
|
897
846
|
path,
|
|
898
847
|
stream.label,
|
|
899
848
|
incrementalDataRecord
|
|
@@ -908,17 +857,13 @@ function completeAsyncIteratorValue(exeContext, itemType, fieldGroup, info, path
|
|
|
908
857
|
break;
|
|
909
858
|
}
|
|
910
859
|
} catch (rawError) {
|
|
911
|
-
throw locatedError(
|
|
912
|
-
rawError,
|
|
913
|
-
fieldGroup,
|
|
914
|
-
pathToArray(path)
|
|
915
|
-
);
|
|
860
|
+
throw locatedError(rawError, fieldGroup, pathToArray(path));
|
|
916
861
|
}
|
|
917
862
|
if (completeListItemValue(
|
|
918
863
|
iteration.value,
|
|
919
864
|
completedResults,
|
|
920
865
|
exeContext,
|
|
921
|
-
|
|
866
|
+
itemTypeRef,
|
|
922
867
|
fieldGroup,
|
|
923
868
|
info,
|
|
924
869
|
itemPath,
|
|
@@ -940,16 +885,23 @@ function completeLeafValue(returnType, result) {
|
|
|
940
885
|
}
|
|
941
886
|
return serializedResult;
|
|
942
887
|
}
|
|
943
|
-
function completeAbstractValue(exeContext,
|
|
888
|
+
function completeAbstractValue(exeContext, returnTypeName, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
944
889
|
var _a;
|
|
945
|
-
const resolveTypeFn = (_a =
|
|
890
|
+
const resolveTypeFn = (_a = exeContext.partialSchema.getAbstractTypeResolver(returnTypeName)) != null ? _a : exeContext.typeResolver;
|
|
946
891
|
const contextValue = exeContext.contextValue;
|
|
947
892
|
const runtimeTypeName = resolveTypeFn(result, contextValue, info);
|
|
948
893
|
if (isPromise(runtimeTypeName)) {
|
|
949
894
|
return runtimeTypeName.then(
|
|
950
895
|
(resolvedRuntimeTypeName) => completeObjectValue(
|
|
951
896
|
exeContext,
|
|
952
|
-
ensureValidRuntimeType(
|
|
897
|
+
ensureValidRuntimeType(
|
|
898
|
+
resolvedRuntimeTypeName,
|
|
899
|
+
exeContext,
|
|
900
|
+
returnTypeName,
|
|
901
|
+
fieldGroup,
|
|
902
|
+
info,
|
|
903
|
+
result
|
|
904
|
+
),
|
|
953
905
|
fieldGroup,
|
|
954
906
|
path,
|
|
955
907
|
result,
|
|
@@ -959,48 +911,63 @@ function completeAbstractValue(exeContext, returnType, fieldGroup, info, path, r
|
|
|
959
911
|
}
|
|
960
912
|
return completeObjectValue(
|
|
961
913
|
exeContext,
|
|
962
|
-
ensureValidRuntimeType(
|
|
914
|
+
ensureValidRuntimeType(
|
|
915
|
+
runtimeTypeName,
|
|
916
|
+
exeContext,
|
|
917
|
+
returnTypeName,
|
|
918
|
+
fieldGroup,
|
|
919
|
+
info,
|
|
920
|
+
result
|
|
921
|
+
),
|
|
963
922
|
fieldGroup,
|
|
964
923
|
path,
|
|
965
924
|
result,
|
|
966
925
|
incrementalDataRecord
|
|
967
926
|
);
|
|
968
927
|
}
|
|
969
|
-
function ensureValidRuntimeType(runtimeTypeName, exeContext) {
|
|
970
|
-
if (
|
|
928
|
+
function ensureValidRuntimeType(runtimeTypeName, exeContext, returnTypeName, fieldGroup, info, result) {
|
|
929
|
+
if (runtimeTypeName == null) {
|
|
971
930
|
throw new GraphQLError(
|
|
972
|
-
`
|
|
931
|
+
`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.`,
|
|
932
|
+
{ nodes: fieldGroup }
|
|
973
933
|
);
|
|
974
934
|
}
|
|
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) {
|
|
935
|
+
if (typeof runtimeTypeName !== "string") {
|
|
981
936
|
throw new GraphQLError(
|
|
982
|
-
`
|
|
983
|
-
runtimeType
|
|
984
|
-
)}" type is not a possible type for "${runtimeTypeName}".`
|
|
937
|
+
`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
938
|
);
|
|
986
|
-
} else {
|
|
987
|
-
return runtimeTypeName;
|
|
988
939
|
}
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
if (
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
} else if ("__implementedBy" in runtimeType) {
|
|
1000
|
-
return "GraphQLInterfaceType";
|
|
940
|
+
const partialSchema = exeContext.partialSchema;
|
|
941
|
+
const iface = partialSchema.getInterfaceType(returnTypeName);
|
|
942
|
+
if (iface) {
|
|
943
|
+
if (partialSchema.isDefined(runtimeTypeName) && !partialSchema.isObjectType(runtimeTypeName)) {
|
|
944
|
+
throw new GraphQLError(
|
|
945
|
+
`Abstract type "${returnTypeName}" was resolved to a non-object type "${runtimeTypeName}".`,
|
|
946
|
+
{ nodes: fieldGroup }
|
|
947
|
+
);
|
|
948
|
+
}
|
|
949
|
+
partialSchema.addInterfaceImplementation(returnTypeName, runtimeTypeName);
|
|
1001
950
|
} else {
|
|
1002
|
-
|
|
951
|
+
if (!partialSchema.isDefined(runtimeTypeName)) {
|
|
952
|
+
throw new GraphQLError(
|
|
953
|
+
`Abstract type "${returnTypeName}" was resolved to a type "${runtimeTypeName}" that does not exist inside the schema.`,
|
|
954
|
+
{ nodes: fieldGroup }
|
|
955
|
+
);
|
|
956
|
+
}
|
|
957
|
+
if (!partialSchema.isObjectType(runtimeTypeName)) {
|
|
958
|
+
throw new GraphQLError(
|
|
959
|
+
`Abstract type "${returnTypeName}" was resolved to a non-object type "${runtimeTypeName}".`,
|
|
960
|
+
{ nodes: fieldGroup }
|
|
961
|
+
);
|
|
962
|
+
}
|
|
963
|
+
if (!exeContext.partialSchema.isSubType(returnTypeName, runtimeTypeName)) {
|
|
964
|
+
throw new GraphQLError(
|
|
965
|
+
`Runtime Object type "${runtimeTypeName}" is not a possible type for "${returnTypeName}".`,
|
|
966
|
+
{ nodes: fieldGroup }
|
|
967
|
+
);
|
|
968
|
+
}
|
|
1003
969
|
}
|
|
970
|
+
return runtimeTypeName;
|
|
1004
971
|
}
|
|
1005
972
|
function completeObjectValue(exeContext, returnTypeName, fieldGroup, path, result, incrementalDataRecord) {
|
|
1006
973
|
return collectAndExecuteSubfields(
|
|
@@ -1145,12 +1112,17 @@ var defaultFieldResolver = (
|
|
|
1145
1112
|
);
|
|
1146
1113
|
function getOperationRootTypeName(operation) {
|
|
1147
1114
|
switch (operation.operation) {
|
|
1148
|
-
case
|
|
1115
|
+
case "query":
|
|
1149
1116
|
return "Query";
|
|
1150
|
-
case
|
|
1117
|
+
case "mutation":
|
|
1151
1118
|
return "Mutation";
|
|
1152
|
-
case
|
|
1119
|
+
case "subscription":
|
|
1153
1120
|
return "Subscription";
|
|
1121
|
+
default:
|
|
1122
|
+
invariant(
|
|
1123
|
+
false,
|
|
1124
|
+
`Operation "${operation.operation}" is not a part of GraphQL spec`
|
|
1125
|
+
);
|
|
1154
1126
|
}
|
|
1155
1127
|
}
|
|
1156
1128
|
function executeDeferredFragment(exeContext, parentTypeName, sourceValue, fields, label, path, parentContext) {
|
|
@@ -1182,7 +1154,7 @@ function executeDeferredFragment(exeContext, parentTypeName, sourceValue, fields
|
|
|
1182
1154
|
}
|
|
1183
1155
|
incrementalDataRecord.addData(promiseOrData);
|
|
1184
1156
|
}
|
|
1185
|
-
function executeStreamField(path, itemPath, item, exeContext, fieldGroup, info,
|
|
1157
|
+
function executeStreamField(path, itemPath, item, exeContext, fieldGroup, info, itemTypeRef, label, parentContext) {
|
|
1186
1158
|
const incrementalDataRecord = new StreamItemsRecord({
|
|
1187
1159
|
label,
|
|
1188
1160
|
path: itemPath,
|
|
@@ -1192,7 +1164,7 @@ function executeStreamField(path, itemPath, item, exeContext, fieldGroup, info,
|
|
|
1192
1164
|
if (isPromise(item)) {
|
|
1193
1165
|
const completedItems = completePromisedValue(
|
|
1194
1166
|
exeContext,
|
|
1195
|
-
|
|
1167
|
+
itemTypeRef,
|
|
1196
1168
|
fieldGroup,
|
|
1197
1169
|
info,
|
|
1198
1170
|
itemPath,
|
|
@@ -1214,7 +1186,7 @@ function executeStreamField(path, itemPath, item, exeContext, fieldGroup, info,
|
|
|
1214
1186
|
try {
|
|
1215
1187
|
completedItem = completeValue(
|
|
1216
1188
|
exeContext,
|
|
1217
|
-
|
|
1189
|
+
itemTypeRef,
|
|
1218
1190
|
fieldGroup,
|
|
1219
1191
|
info,
|
|
1220
1192
|
itemPath,
|
|
@@ -1225,7 +1197,7 @@ function executeStreamField(path, itemPath, item, exeContext, fieldGroup, info,
|
|
|
1225
1197
|
handleFieldError(
|
|
1226
1198
|
rawError,
|
|
1227
1199
|
exeContext,
|
|
1228
|
-
|
|
1200
|
+
itemTypeRef,
|
|
1229
1201
|
fieldGroup,
|
|
1230
1202
|
itemPath,
|
|
1231
1203
|
incrementalDataRecord
|
|
@@ -1244,7 +1216,7 @@ function executeStreamField(path, itemPath, item, exeContext, fieldGroup, info,
|
|
|
1244
1216
|
handleFieldError(
|
|
1245
1217
|
rawError,
|
|
1246
1218
|
exeContext,
|
|
1247
|
-
|
|
1219
|
+
itemTypeRef,
|
|
1248
1220
|
fieldGroup,
|
|
1249
1221
|
itemPath,
|
|
1250
1222
|
incrementalDataRecord
|
|
@@ -1265,7 +1237,7 @@ function executeStreamField(path, itemPath, item, exeContext, fieldGroup, info,
|
|
|
1265
1237
|
incrementalDataRecord.addItems([completedItem]);
|
|
1266
1238
|
return incrementalDataRecord;
|
|
1267
1239
|
}
|
|
1268
|
-
function executeStreamAsyncIteratorItem(asyncIterator, exeContext, fieldGroup, info,
|
|
1240
|
+
function executeStreamAsyncIteratorItem(asyncIterator, exeContext, fieldGroup, info, itemTypeRef, incrementalDataRecord, path, itemPath) {
|
|
1269
1241
|
return __async(this, null, function* () {
|
|
1270
1242
|
let item;
|
|
1271
1243
|
try {
|
|
@@ -1276,17 +1248,13 @@ function executeStreamAsyncIteratorItem(asyncIterator, exeContext, fieldGroup, i
|
|
|
1276
1248
|
}
|
|
1277
1249
|
item = value;
|
|
1278
1250
|
} catch (rawError) {
|
|
1279
|
-
throw locatedError(
|
|
1280
|
-
rawError,
|
|
1281
|
-
fieldGroup,
|
|
1282
|
-
pathToArray(path)
|
|
1283
|
-
);
|
|
1251
|
+
throw locatedError(rawError, fieldGroup, pathToArray(path));
|
|
1284
1252
|
}
|
|
1285
1253
|
let completedItem;
|
|
1286
1254
|
try {
|
|
1287
1255
|
completedItem = completeValue(
|
|
1288
1256
|
exeContext,
|
|
1289
|
-
|
|
1257
|
+
itemTypeRef,
|
|
1290
1258
|
fieldGroup,
|
|
1291
1259
|
info,
|
|
1292
1260
|
itemPath,
|
|
@@ -1298,7 +1266,7 @@ function executeStreamAsyncIteratorItem(asyncIterator, exeContext, fieldGroup, i
|
|
|
1298
1266
|
handleFieldError(
|
|
1299
1267
|
rawError,
|
|
1300
1268
|
exeContext,
|
|
1301
|
-
|
|
1269
|
+
itemTypeRef,
|
|
1302
1270
|
fieldGroup,
|
|
1303
1271
|
itemPath,
|
|
1304
1272
|
incrementalDataRecord
|
|
@@ -1312,7 +1280,7 @@ function executeStreamAsyncIteratorItem(asyncIterator, exeContext, fieldGroup, i
|
|
|
1312
1280
|
handleFieldError(
|
|
1313
1281
|
rawError,
|
|
1314
1282
|
exeContext,
|
|
1315
|
-
|
|
1283
|
+
itemTypeRef,
|
|
1316
1284
|
fieldGroup,
|
|
1317
1285
|
itemPath,
|
|
1318
1286
|
incrementalDataRecord
|
|
@@ -1322,7 +1290,7 @@ function executeStreamAsyncIteratorItem(asyncIterator, exeContext, fieldGroup, i
|
|
|
1322
1290
|
}
|
|
1323
1291
|
});
|
|
1324
1292
|
}
|
|
1325
|
-
function executeStreamAsyncIterator(initialIndex, asyncIterator, exeContext, fieldGroup, info,
|
|
1293
|
+
function executeStreamAsyncIterator(initialIndex, asyncIterator, exeContext, fieldGroup, info, itemTypeRef, path, label, parentContext) {
|
|
1326
1294
|
return __async(this, null, function* () {
|
|
1327
1295
|
let index = initialIndex;
|
|
1328
1296
|
let previousIncrementalDataRecord = parentContext != null ? parentContext : void 0;
|
|
@@ -1342,7 +1310,7 @@ function executeStreamAsyncIterator(initialIndex, asyncIterator, exeContext, fie
|
|
|
1342
1310
|
exeContext,
|
|
1343
1311
|
fieldGroup,
|
|
1344
1312
|
info,
|
|
1345
|
-
|
|
1313
|
+
itemTypeRef,
|
|
1346
1314
|
incrementalDataRecord,
|
|
1347
1315
|
path,
|
|
1348
1316
|
itemPath
|
|
@@ -1554,11 +1522,19 @@ var StreamItemsRecord = class {
|
|
|
1554
1522
|
this.isCompletedAsyncIterator = true;
|
|
1555
1523
|
}
|
|
1556
1524
|
};
|
|
1525
|
+
function isIncrementalExecutionResult(result) {
|
|
1526
|
+
return "initialResult" in result;
|
|
1527
|
+
}
|
|
1528
|
+
function isTotalExecutionResult(result) {
|
|
1529
|
+
return !("initialResult" in result);
|
|
1530
|
+
}
|
|
1557
1531
|
export {
|
|
1558
1532
|
assertValidExecutionArguments,
|
|
1559
1533
|
buildResolveInfo,
|
|
1560
1534
|
defaultFieldResolver,
|
|
1561
1535
|
defaultTypeResolver,
|
|
1562
1536
|
executeWithoutSchema,
|
|
1563
|
-
getOperationRootTypeName
|
|
1537
|
+
getOperationRootTypeName,
|
|
1538
|
+
isIncrementalExecutionResult,
|
|
1539
|
+
isTotalExecutionResult
|
|
1564
1540
|
};
|