@graphitation/supermassive 2.6.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 +17 -1
- 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 +11 -20
- package/lib/benchmarks/index.js.map +3 -3
- package/lib/benchmarks/index.mjs +12 -23
- package/lib/benchmarks/index.mjs.map +2 -2
- package/lib/benchmarks/swapi-schema/index.d.ts +4 -2
- package/lib/benchmarks/swapi-schema/index.d.ts.map +1 -1
- package/lib/benchmarks/swapi-schema/index.js +8 -2
- package/lib/benchmarks/swapi-schema/index.js.map +2 -2
- package/lib/benchmarks/swapi-schema/index.mjs +8 -2
- package/lib/benchmarks/swapi-schema/index.mjs.map +2 -2
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.d.ts +7 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.d.ts.map +1 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.js +916 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.js.map +7 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.mjs +903 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.mjs.map +7 -0
- package/lib/benchmarks/swapi-schema/resolvers.d.ts.map +1 -1
- package/lib/benchmarks/swapi-schema/resolvers.js +53 -17
- package/lib/benchmarks/swapi-schema/resolvers.js.map +2 -2
- package/lib/benchmarks/swapi-schema/resolvers.mjs +54 -18
- package/lib/benchmarks/swapi-schema/resolvers.mjs.map +2 -2
- package/lib/collectFields.d.ts +27 -10
- package/lib/collectFields.d.ts.map +1 -1
- package/lib/collectFields.js +146 -80
- package/lib/collectFields.js.map +3 -3
- package/lib/collectFields.mjs +143 -81
- 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 +53 -16
- package/lib/executeWithoutSchema.d.ts.map +1 -1
- package/lib/executeWithoutSchema.js +1076 -274
- package/lib/executeWithoutSchema.js.map +3 -3
- package/lib/executeWithoutSchema.mjs +1092 -281
- package/lib/executeWithoutSchema.mjs.map +3 -3
- package/lib/index.d.ts +3 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -7
- package/lib/index.js.map +2 -2
- package/lib/index.mjs +3 -10
- package/lib/index.mjs.map +2 -2
- package/lib/jsutils/AccumulatorMap.d.ts +8 -0
- package/lib/jsutils/AccumulatorMap.d.ts.map +1 -0
- package/lib/jsutils/AccumulatorMap.js +36 -0
- package/lib/jsutils/AccumulatorMap.js.map +7 -0
- package/lib/jsutils/AccumulatorMap.mjs +17 -0
- package/lib/jsutils/AccumulatorMap.mjs.map +7 -0
- package/lib/jsutils/didYouMean.d.ts +1 -2
- package/lib/jsutils/didYouMean.d.ts.map +1 -1
- package/lib/jsutils/didYouMean.js.map +2 -2
- package/lib/jsutils/didYouMean.mjs.map +2 -2
- package/lib/jsutils/instanceOf.js.map +2 -2
- package/lib/jsutils/instanceOf.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 +3 -2
- 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/subscribeWithoutSchema.d.ts +3 -35
- package/lib/subscribeWithoutSchema.d.ts.map +1 -1
- package/lib/subscribeWithoutSchema.js +1 -163
- package/lib/subscribeWithoutSchema.js.map +2 -2
- package/lib/subscribeWithoutSchema.mjs +2 -175
- package/lib/subscribeWithoutSchema.mjs.map +2 -2
- package/lib/types.d.ts +71 -29
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +14 -0
- package/lib/types.js.map +2 -2
- package/lib/types.mjs +11 -0
- package/lib/types.mjs.map +3 -3
- 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/utilities/annotateDocumentGraphQLTransform.d.ts +3 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.d.ts.map +1 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.js +34 -0
- 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/mergeResolvers.d.ts +1 -1
- package/lib/utilities/mergeResolvers.d.ts.map +1 -1
- package/lib/utilities/mergeResolvers.js.map +2 -2
- package/lib/utilities/mergeResolvers.mjs.map +2 -2
- 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 -13
- package/lib/values.d.ts.map +1 -1
- package/lib/values.js +83 -75
- package/lib/values.js.map +2 -2
- package/lib/values.mjs +85 -83
- package/lib/values.mjs.map +2 -2
- package/package.json +8 -9
- 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 -79
- package/lib/directives.d.ts.map +0 -1
- package/lib/directives.js +0 -160
- package/lib/directives.js.map +0 -7
- package/lib/directives.mjs +0 -146
- 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
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
6
23
|
var __export = (target, all) => {
|
|
7
24
|
for (var name in all)
|
|
8
25
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,10 +33,29 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
33
|
return to;
|
|
17
34
|
};
|
|
18
35
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
|
+
var __async = (__this, __arguments, generator) => {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
var fulfilled = (value) => {
|
|
39
|
+
try {
|
|
40
|
+
step(generator.next(value));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var rejected = (value) => {
|
|
46
|
+
try {
|
|
47
|
+
step(generator.throw(value));
|
|
48
|
+
} catch (e) {
|
|
49
|
+
reject(e);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
53
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
54
|
+
});
|
|
55
|
+
};
|
|
19
56
|
var executeWithoutSchema_exports = {};
|
|
20
57
|
__export(executeWithoutSchema_exports, {
|
|
21
58
|
assertValidExecutionArguments: () => assertValidExecutionArguments,
|
|
22
|
-
buildExecutionContext: () => buildExecutionContext,
|
|
23
59
|
buildResolveInfo: () => buildResolveInfo,
|
|
24
60
|
defaultFieldResolver: () => defaultFieldResolver,
|
|
25
61
|
defaultTypeResolver: () => defaultTypeResolver,
|
|
@@ -38,51 +74,26 @@ var import_isPromise = require("./jsutils/isPromise");
|
|
|
38
74
|
var import_Path = require("./jsutils/Path");
|
|
39
75
|
var import_promiseForObject = require("./jsutils/promiseForObject");
|
|
40
76
|
var import_promiseReduce = require("./jsutils/promiseReduce");
|
|
41
|
-
var import_definition = require("./definition");
|
|
42
|
-
var import_mergeResolvers = require("./utilities/mergeResolvers");
|
|
43
|
-
var import_typeNameFromAST = require("./utilities/typeNameFromAST");
|
|
44
77
|
var import_values = require("./values");
|
|
45
78
|
var import_array = require("./utilities/array");
|
|
79
|
+
var import_isAsyncIterable = require("./jsutils/isAsyncIterable");
|
|
80
|
+
var import_mapAsyncIterator = require("./utilities/mapAsyncIterator");
|
|
81
|
+
var import_directives = require("./schema/directives");
|
|
82
|
+
var import_memoize3 = require("./jsutils/memoize3");
|
|
83
|
+
var import_fragment = require("./schema/fragment");
|
|
84
|
+
var import_reference = require("./schema/reference");
|
|
85
|
+
var import_getSchemaFragment = require("./utilities/getSchemaFragment");
|
|
86
|
+
var import_mergeDefinitions = require("./utilities/mergeDefinitions");
|
|
87
|
+
const collectSubfields = (0, import_memoize3.memoize3)(
|
|
88
|
+
(exeContext, returnTypeName, fieldGroup) => (0, import_collectFields.collectSubfields)(exeContext, returnTypeName.name, fieldGroup)
|
|
89
|
+
);
|
|
46
90
|
function executeWithoutSchema(args) {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
schemaResolvers,
|
|
50
|
-
document,
|
|
51
|
-
rootValue,
|
|
52
|
-
contextValue,
|
|
53
|
-
variableValues,
|
|
54
|
-
operationName,
|
|
55
|
-
fieldResolver,
|
|
56
|
-
typeResolver,
|
|
57
|
-
fieldExecutionHooks
|
|
58
|
-
} = args;
|
|
59
|
-
const combinedResolvers = schemaResolvers ? (0, import_mergeResolvers.mergeResolvers)(resolvers, schemaResolvers) : resolvers;
|
|
60
|
-
assertValidExecutionArguments(document, variableValues);
|
|
61
|
-
const exeContext = buildExecutionContext(
|
|
62
|
-
combinedResolvers,
|
|
63
|
-
document,
|
|
64
|
-
rootValue,
|
|
65
|
-
contextValue,
|
|
66
|
-
variableValues,
|
|
67
|
-
operationName,
|
|
68
|
-
fieldResolver,
|
|
69
|
-
typeResolver,
|
|
70
|
-
fieldExecutionHooks
|
|
71
|
-
);
|
|
72
|
-
if (!("resolvers" in exeContext)) {
|
|
91
|
+
const exeContext = buildExecutionContext(args);
|
|
92
|
+
if (!("schemaTypes" in exeContext)) {
|
|
73
93
|
return { errors: exeContext };
|
|
74
94
|
} else {
|
|
75
|
-
|
|
76
|
-
return buildResponse(exeContext, data);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function buildResponse(exeContext, data) {
|
|
80
|
-
if ((0, import_isPromise.isPromise)(data)) {
|
|
81
|
-
return data.then(
|
|
82
|
-
(resolved) => buildResponse(exeContext, resolved)
|
|
83
|
-
);
|
|
95
|
+
return executeOperation(exeContext);
|
|
84
96
|
}
|
|
85
|
-
return exeContext.errors.length === 0 ? { data } : { errors: exeContext.errors, data };
|
|
86
97
|
}
|
|
87
98
|
function assertValidExecutionArguments(document, rawVariableValues) {
|
|
88
99
|
(0, import_devAssert.devAssert)(document, "Must provide document.");
|
|
@@ -91,8 +102,23 @@ function assertValidExecutionArguments(document, rawVariableValues) {
|
|
|
91
102
|
"Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided."
|
|
92
103
|
);
|
|
93
104
|
}
|
|
94
|
-
function buildExecutionContext(
|
|
105
|
+
function buildExecutionContext(args) {
|
|
95
106
|
var _a, _b;
|
|
107
|
+
const {
|
|
108
|
+
resolvers,
|
|
109
|
+
schemaFragment: explicitSchemaFragment,
|
|
110
|
+
document,
|
|
111
|
+
rootValue,
|
|
112
|
+
contextValue,
|
|
113
|
+
buildContextValue,
|
|
114
|
+
variableValues,
|
|
115
|
+
operationName,
|
|
116
|
+
fieldResolver,
|
|
117
|
+
typeResolver,
|
|
118
|
+
subscribeFieldResolver,
|
|
119
|
+
fieldExecutionHooks
|
|
120
|
+
} = args;
|
|
121
|
+
assertValidExecutionArguments(document, variableValues);
|
|
96
122
|
let operation;
|
|
97
123
|
const fragments = /* @__PURE__ */ Object.create(null);
|
|
98
124
|
for (const definition of document.definitions) {
|
|
@@ -122,66 +148,146 @@ function buildExecutionContext(resolvers, document, rootValue, contextValue, raw
|
|
|
122
148
|
}
|
|
123
149
|
return [new import_graphql.GraphQLError("Must provide an operation.")];
|
|
124
150
|
}
|
|
151
|
+
let schemaFragment = explicitSchemaFragment;
|
|
152
|
+
if (!schemaFragment) {
|
|
153
|
+
schemaFragment = (0, import_getSchemaFragment.getSchemaFragment)(operation);
|
|
154
|
+
if (schemaFragment && !schemaFragment.__merged) {
|
|
155
|
+
(0, import_mergeDefinitions.mergeSchemaDefinitions)(
|
|
156
|
+
schemaFragment,
|
|
157
|
+
Object.values(fragments).map((fragmentDef) => (0, import_getSchemaFragment.getSchemaFragment)(fragmentDef)).filter((f) => Boolean(f))
|
|
158
|
+
);
|
|
159
|
+
schemaFragment.__merged = true;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (!schemaFragment) {
|
|
163
|
+
return [new import_graphql.GraphQLError("Must provide schema fragment.")];
|
|
164
|
+
}
|
|
125
165
|
const variableDefinitions = (_b = operation.variableDefinitions) != null ? _b : [];
|
|
166
|
+
const schemaTypes = new import_fragment.SchemaFragment(schemaFragment, resolvers);
|
|
126
167
|
const coercedVariableValues = (0, import_values.getVariableValues)(
|
|
127
|
-
|
|
168
|
+
schemaTypes,
|
|
128
169
|
variableDefinitions,
|
|
129
|
-
|
|
170
|
+
variableValues != null ? variableValues : {},
|
|
130
171
|
{ maxErrors: 50 }
|
|
131
172
|
);
|
|
132
173
|
if (coercedVariableValues.errors) {
|
|
133
174
|
return coercedVariableValues.errors;
|
|
134
175
|
}
|
|
135
176
|
return {
|
|
136
|
-
|
|
177
|
+
schemaTypes,
|
|
137
178
|
fragments,
|
|
138
179
|
rootValue,
|
|
139
|
-
contextValue,
|
|
180
|
+
contextValue: buildContextValue ? buildContextValue(contextValue) : contextValue,
|
|
181
|
+
buildContextValue,
|
|
140
182
|
operation,
|
|
141
183
|
variableValues: coercedVariableValues.coerced,
|
|
142
184
|
fieldResolver: fieldResolver != null ? fieldResolver : defaultFieldResolver,
|
|
143
185
|
typeResolver: typeResolver != null ? typeResolver : defaultTypeResolver,
|
|
186
|
+
subscribeFieldResolver: subscribeFieldResolver != null ? subscribeFieldResolver : defaultFieldResolver,
|
|
144
187
|
errors: [],
|
|
145
|
-
fieldExecutionHooks
|
|
188
|
+
fieldExecutionHooks,
|
|
189
|
+
subsequentPayloads: /* @__PURE__ */ new Set()
|
|
146
190
|
};
|
|
147
191
|
}
|
|
148
|
-
function
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
);
|
|
192
|
+
function buildPerEventExecutionContext(exeContext, payload) {
|
|
193
|
+
return __spreadProps(__spreadValues({}, exeContext), {
|
|
194
|
+
contextValue: exeContext.buildContextValue ? exeContext.buildContextValue(exeContext.contextValue) : exeContext.contextValue,
|
|
195
|
+
rootValue: payload,
|
|
196
|
+
subsequentPayloads: /* @__PURE__ */ new Set(),
|
|
197
|
+
errors: []
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
function executeOperation(exeContext) {
|
|
201
|
+
const { operation, rootValue } = exeContext;
|
|
202
|
+
const rootTypeName = getOperationRootTypeName(operation);
|
|
203
|
+
const { groupedFieldSet, patches } = (0, import_collectFields.collectFields)(exeContext, rootTypeName);
|
|
159
204
|
const path = void 0;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
205
|
+
let result;
|
|
206
|
+
switch (operation.operation) {
|
|
207
|
+
case import_graphql.OperationTypeNode.QUERY:
|
|
208
|
+
result = executeFields(
|
|
209
|
+
exeContext,
|
|
210
|
+
rootTypeName,
|
|
211
|
+
rootValue,
|
|
212
|
+
path,
|
|
213
|
+
groupedFieldSet,
|
|
214
|
+
void 0
|
|
215
|
+
);
|
|
216
|
+
result = buildResponse(exeContext, result);
|
|
217
|
+
break;
|
|
218
|
+
case import_graphql.OperationTypeNode.MUTATION:
|
|
219
|
+
result = executeFieldsSerially(
|
|
220
|
+
exeContext,
|
|
221
|
+
rootTypeName,
|
|
222
|
+
rootValue,
|
|
223
|
+
path,
|
|
224
|
+
groupedFieldSet
|
|
225
|
+
);
|
|
226
|
+
result = buildResponse(exeContext, result);
|
|
227
|
+
break;
|
|
228
|
+
case import_graphql.OperationTypeNode.SUBSCRIPTION: {
|
|
229
|
+
const resultOrStreamOrPromise = createSourceEventStream(exeContext);
|
|
230
|
+
result = mapResultOrEventStreamOrPromise(
|
|
231
|
+
resultOrStreamOrPromise,
|
|
232
|
+
exeContext,
|
|
233
|
+
rootTypeName,
|
|
234
|
+
path,
|
|
235
|
+
groupedFieldSet
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
for (const patch of patches) {
|
|
240
|
+
const { label, groupedFieldSet: patchGroupedFieldSet } = patch;
|
|
241
|
+
executeDeferredFragment(
|
|
242
|
+
exeContext,
|
|
243
|
+
rootTypeName,
|
|
244
|
+
rootValue,
|
|
245
|
+
patchGroupedFieldSet,
|
|
246
|
+
label,
|
|
247
|
+
path
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
return result;
|
|
251
|
+
}
|
|
252
|
+
function buildResponse(exeContext, data) {
|
|
253
|
+
if ((0, import_isPromise.isPromise)(data)) {
|
|
254
|
+
return data.then(
|
|
255
|
+
(resolved) => buildResponse(exeContext, resolved),
|
|
256
|
+
(error) => {
|
|
164
257
|
exeContext.errors.push(error);
|
|
165
|
-
return
|
|
166
|
-
}
|
|
258
|
+
return buildResponse(exeContext, null);
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
try {
|
|
263
|
+
const initialResult = exeContext.errors.length === 0 ? { data } : { errors: exeContext.errors, data };
|
|
264
|
+
if (exeContext.subsequentPayloads.size > 0) {
|
|
265
|
+
return {
|
|
266
|
+
initialResult: __spreadProps(__spreadValues({}, initialResult), {
|
|
267
|
+
hasNext: true
|
|
268
|
+
}),
|
|
269
|
+
subsequentResults: yieldSubsequentPayloads(exeContext)
|
|
270
|
+
};
|
|
271
|
+
} else {
|
|
272
|
+
return initialResult;
|
|
167
273
|
}
|
|
168
|
-
return result;
|
|
169
274
|
} catch (error) {
|
|
170
275
|
exeContext.errors.push(error);
|
|
171
|
-
return null;
|
|
276
|
+
return buildResponse(exeContext, null);
|
|
172
277
|
}
|
|
173
278
|
}
|
|
174
|
-
function executeFieldsSerially(exeContext, parentTypeName, sourceValue, path,
|
|
279
|
+
function executeFieldsSerially(exeContext, parentTypeName, sourceValue, path, groupedFieldSet) {
|
|
175
280
|
return (0, import_promiseReduce.promiseReduce)(
|
|
176
|
-
|
|
177
|
-
(results, [responseName,
|
|
281
|
+
groupedFieldSet,
|
|
282
|
+
(results, [responseName, fieldGroup]) => {
|
|
178
283
|
const fieldPath = (0, import_Path.addPath)(path, responseName, parentTypeName);
|
|
179
284
|
const result = executeField(
|
|
180
285
|
exeContext,
|
|
181
286
|
parentTypeName,
|
|
182
287
|
sourceValue,
|
|
183
|
-
|
|
184
|
-
fieldPath
|
|
288
|
+
fieldGroup,
|
|
289
|
+
fieldPath,
|
|
290
|
+
void 0
|
|
185
291
|
);
|
|
186
292
|
if (result === void 0) {
|
|
187
293
|
return results;
|
|
@@ -198,17 +304,18 @@ function executeFieldsSerially(exeContext, parentTypeName, sourceValue, path, fi
|
|
|
198
304
|
/* @__PURE__ */ Object.create(null)
|
|
199
305
|
);
|
|
200
306
|
}
|
|
201
|
-
function executeFields(exeContext, parentTypeName, sourceValue, path,
|
|
307
|
+
function executeFields(exeContext, parentTypeName, sourceValue, path, groupedFieldSet, incrementalDataRecord) {
|
|
202
308
|
const results = /* @__PURE__ */ Object.create(null);
|
|
203
309
|
let containsPromise = false;
|
|
204
|
-
for (const [responseName,
|
|
310
|
+
for (const [responseName, fieldGroup] of groupedFieldSet) {
|
|
205
311
|
const fieldPath = (0, import_Path.addPath)(path, responseName, parentTypeName);
|
|
206
312
|
const result = executeField(
|
|
207
313
|
exeContext,
|
|
208
314
|
parentTypeName,
|
|
209
315
|
sourceValue,
|
|
210
|
-
|
|
211
|
-
fieldPath
|
|
316
|
+
fieldGroup,
|
|
317
|
+
fieldPath,
|
|
318
|
+
incrementalDataRecord
|
|
212
319
|
);
|
|
213
320
|
if (result !== void 0) {
|
|
214
321
|
results[responseName] = result;
|
|
@@ -222,54 +329,164 @@ function executeFields(exeContext, parentTypeName, sourceValue, path, fields) {
|
|
|
222
329
|
}
|
|
223
330
|
return (0, import_promiseForObject.promiseForObject)(results);
|
|
224
331
|
}
|
|
225
|
-
function executeField(exeContext, parentTypeName, source,
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
332
|
+
function executeField(exeContext, parentTypeName, source, fieldGroup, path, incrementalDataRecord) {
|
|
333
|
+
var _a;
|
|
334
|
+
const schemaTypes = exeContext.schemaTypes;
|
|
335
|
+
const fieldName = fieldGroup[0].name.value;
|
|
336
|
+
const fieldDef = schemaTypes.getField(parentTypeName, fieldName);
|
|
337
|
+
if (fieldDef === void 0) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const returnTypeRef = schemaTypes.getTypeReference(fieldDef);
|
|
341
|
+
const resolveFn = (_a = schemaTypes.getFieldResolver(parentTypeName, fieldName)) != null ? _a : exeContext.fieldResolver;
|
|
342
|
+
const info = buildResolveInfo(
|
|
343
|
+
exeContext,
|
|
344
|
+
fieldName,
|
|
345
|
+
fieldGroup,
|
|
346
|
+
parentTypeName,
|
|
347
|
+
(0, import_reference.typeNameFromReference)(returnTypeRef),
|
|
348
|
+
path
|
|
349
|
+
);
|
|
350
|
+
return resolveAndCompleteField(
|
|
351
|
+
exeContext,
|
|
352
|
+
parentTypeName,
|
|
353
|
+
returnTypeRef,
|
|
354
|
+
fieldDef,
|
|
355
|
+
fieldGroup,
|
|
356
|
+
info,
|
|
357
|
+
path,
|
|
358
|
+
resolveFn,
|
|
359
|
+
source,
|
|
360
|
+
incrementalDataRecord
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
function createSourceEventStream(exeContext) {
|
|
364
|
+
try {
|
|
365
|
+
const eventStream = executeSubscriptionImpl(exeContext);
|
|
366
|
+
if ((0, import_isPromise.isPromise)(eventStream)) {
|
|
367
|
+
return eventStream.then(void 0, (error) => ({ errors: [error] }));
|
|
248
368
|
}
|
|
369
|
+
return eventStream;
|
|
370
|
+
} catch (error) {
|
|
371
|
+
return { errors: [error] };
|
|
249
372
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
373
|
+
}
|
|
374
|
+
function executeSubscriptionImpl(exeContext) {
|
|
375
|
+
var _a;
|
|
376
|
+
const { operation, rootValue, schemaTypes } = exeContext;
|
|
377
|
+
const rootTypeName = getOperationRootTypeName(operation);
|
|
378
|
+
const { groupedFieldSet } = (0, import_collectFields.collectFields)(exeContext, rootTypeName);
|
|
379
|
+
const firstRootField = groupedFieldSet.entries().next().value;
|
|
380
|
+
const [responseName, fieldGroup] = firstRootField;
|
|
381
|
+
const fieldName = fieldGroup[0].name.value;
|
|
382
|
+
const fieldDef = schemaTypes.getField(rootTypeName, fieldName);
|
|
383
|
+
if (!fieldDef) {
|
|
384
|
+
throw new import_graphql.GraphQLError(
|
|
385
|
+
`The subscription field "${fieldName}" is not defined.`,
|
|
386
|
+
{ nodes: fieldGroup }
|
|
387
|
+
);
|
|
253
388
|
}
|
|
389
|
+
const returnTypeRef = schemaTypes.getTypeReference(fieldDef);
|
|
390
|
+
const resolveFn = (_a = schemaTypes.getSubscriptionFieldResolver(rootTypeName, fieldName)) != null ? _a : exeContext.subscribeFieldResolver;
|
|
391
|
+
const path = (0, import_Path.addPath)(void 0, responseName, rootTypeName);
|
|
254
392
|
const info = buildResolveInfo(
|
|
255
393
|
exeContext,
|
|
256
394
|
fieldName,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
returnTypeNode,
|
|
395
|
+
fieldGroup,
|
|
396
|
+
rootTypeName,
|
|
397
|
+
(0, import_reference.typeNameFromReference)(returnTypeRef),
|
|
261
398
|
path
|
|
262
399
|
);
|
|
263
400
|
try {
|
|
264
|
-
const args = (0, import_values.getArgumentValues)(
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
401
|
+
const args = (0, import_values.getArgumentValues)(exeContext, fieldDef, fieldGroup[0]);
|
|
402
|
+
const contextValue = exeContext.contextValue;
|
|
403
|
+
const result = resolveFn(rootValue, args, contextValue, info);
|
|
404
|
+
if ((0, import_isPromise.isPromise)(result)) {
|
|
405
|
+
return result.then(assertEventStream).then(void 0, (error) => {
|
|
406
|
+
throw (0, import_graphql.locatedError)(error, fieldGroup, (0, import_Path.pathToArray)(path));
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
return assertEventStream(result);
|
|
410
|
+
} catch (error) {
|
|
411
|
+
throw (0, import_graphql.locatedError)(error, fieldGroup, (0, import_Path.pathToArray)(path));
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
function assertEventStream(result) {
|
|
415
|
+
if (result instanceof Error) {
|
|
416
|
+
throw result;
|
|
417
|
+
}
|
|
418
|
+
if (!(0, import_isAsyncIterable.isAsyncIterable)(result)) {
|
|
419
|
+
throw new import_graphql.GraphQLError(
|
|
420
|
+
`Subscription field must return Async Iterable. Received: ${(0, import_inspect.inspect)(result)}.`
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
return result;
|
|
424
|
+
}
|
|
425
|
+
function mapResultOrEventStreamOrPromise(resultOrStreamOrPromise, exeContext, parentTypeName, path, groupedFieldSet) {
|
|
426
|
+
if ((0, import_isPromise.isPromise)(resultOrStreamOrPromise)) {
|
|
427
|
+
return resultOrStreamOrPromise.then(
|
|
428
|
+
(resultOrStream) => mapResultOrEventStreamOrPromise(
|
|
429
|
+
resultOrStream,
|
|
430
|
+
exeContext,
|
|
431
|
+
parentTypeName,
|
|
432
|
+
path,
|
|
433
|
+
groupedFieldSet
|
|
434
|
+
)
|
|
268
435
|
);
|
|
436
|
+
} else {
|
|
437
|
+
if (!(0, import_isAsyncIterable.isAsyncIterable)(resultOrStreamOrPromise)) {
|
|
438
|
+
return resultOrStreamOrPromise;
|
|
439
|
+
} else {
|
|
440
|
+
const mapSourceToResponse = (payload) => {
|
|
441
|
+
const perEventContext = buildPerEventExecutionContext(
|
|
442
|
+
exeContext,
|
|
443
|
+
payload
|
|
444
|
+
);
|
|
445
|
+
const data = executeFields(
|
|
446
|
+
exeContext,
|
|
447
|
+
parentTypeName,
|
|
448
|
+
payload,
|
|
449
|
+
path,
|
|
450
|
+
groupedFieldSet,
|
|
451
|
+
void 0
|
|
452
|
+
);
|
|
453
|
+
return buildResponse(perEventContext, data);
|
|
454
|
+
};
|
|
455
|
+
return (0, import_mapAsyncIterator.mapAsyncIterator)(resultOrStreamOrPromise, mapSourceToResponse);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
function buildResolveInfo(exeContext, fieldName, fieldGroup, parentTypeName, returnTypeName, path) {
|
|
460
|
+
return {
|
|
461
|
+
fieldName,
|
|
462
|
+
fieldGroup,
|
|
463
|
+
returnTypeName,
|
|
464
|
+
parentTypeName,
|
|
465
|
+
path,
|
|
466
|
+
fragments: exeContext.fragments,
|
|
467
|
+
rootValue: exeContext.rootValue,
|
|
468
|
+
operation: exeContext.operation,
|
|
469
|
+
variableValues: exeContext.variableValues
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
function handleFieldError(rawError, exeContext, returnTypeRef, fieldGroup, path, incrementalDataRecord) {
|
|
473
|
+
var _a;
|
|
474
|
+
const error = (0, import_graphql.locatedError)(rawError, fieldGroup, (0, import_Path.pathToArray)(path));
|
|
475
|
+
if ((0, import_reference.isNonNullType)(returnTypeRef)) {
|
|
476
|
+
throw error;
|
|
477
|
+
}
|
|
478
|
+
const errors = (_a = incrementalDataRecord == null ? void 0 : incrementalDataRecord.errors) != null ? _a : exeContext.errors;
|
|
479
|
+
errors.push(error);
|
|
480
|
+
}
|
|
481
|
+
function resolveAndCompleteField(exeContext, parentTypeName, returnTypeRef, fieldDefinition, fieldGroup, info, path, resolveFn, source, incrementalDataRecord) {
|
|
482
|
+
const isDefaultResolverUsed = resolveFn === exeContext.fieldResolver;
|
|
483
|
+
const hooks = exeContext.fieldExecutionHooks;
|
|
484
|
+
try {
|
|
485
|
+
const args = (0, import_values.getArgumentValues)(exeContext, fieldDefinition, fieldGroup[0]);
|
|
486
|
+
const contextValue = exeContext.contextValue;
|
|
269
487
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.beforeFieldResolve)) {
|
|
270
488
|
invokeBeforeFieldResolveHook(info, exeContext);
|
|
271
489
|
}
|
|
272
|
-
const contextValue = exeContext.contextValue;
|
|
273
490
|
const result = resolveFn(source, args, contextValue, info);
|
|
274
491
|
let completed;
|
|
275
492
|
if ((0, import_isPromise.isPromise)(result)) {
|
|
@@ -280,11 +497,12 @@ function executeField(exeContext, parentTypeName, source, fieldNodes, path) {
|
|
|
280
497
|
}
|
|
281
498
|
return completeValue(
|
|
282
499
|
exeContext,
|
|
283
|
-
|
|
284
|
-
|
|
500
|
+
returnTypeRef,
|
|
501
|
+
fieldGroup,
|
|
285
502
|
info,
|
|
286
503
|
path,
|
|
287
|
-
resolved
|
|
504
|
+
resolved,
|
|
505
|
+
incrementalDataRecord
|
|
288
506
|
);
|
|
289
507
|
},
|
|
290
508
|
(rawError) => {
|
|
@@ -300,11 +518,12 @@ function executeField(exeContext, parentTypeName, source, fieldNodes, path) {
|
|
|
300
518
|
}
|
|
301
519
|
completed = completeValue(
|
|
302
520
|
exeContext,
|
|
303
|
-
|
|
304
|
-
|
|
521
|
+
returnTypeRef,
|
|
522
|
+
fieldGroup,
|
|
305
523
|
info,
|
|
306
524
|
path,
|
|
307
|
-
result
|
|
525
|
+
result,
|
|
526
|
+
incrementalDataRecord
|
|
308
527
|
);
|
|
309
528
|
}
|
|
310
529
|
if ((0, import_isPromise.isPromise)(completed)) {
|
|
@@ -316,15 +535,19 @@ function executeField(exeContext, parentTypeName, source, fieldNodes, path) {
|
|
|
316
535
|
return resolved;
|
|
317
536
|
},
|
|
318
537
|
(rawError) => {
|
|
319
|
-
const error = (0, import_graphql.locatedError)(
|
|
320
|
-
rawError,
|
|
321
|
-
fieldNodes,
|
|
322
|
-
(0, import_Path.pathToArray)(path)
|
|
323
|
-
);
|
|
538
|
+
const error = (0, import_graphql.locatedError)(rawError, fieldGroup, (0, import_Path.pathToArray)(path));
|
|
324
539
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
325
540
|
invokeAfterFieldCompleteHook(info, exeContext, void 0, error);
|
|
326
541
|
}
|
|
327
|
-
|
|
542
|
+
handleFieldError(
|
|
543
|
+
rawError,
|
|
544
|
+
exeContext,
|
|
545
|
+
returnTypeRef,
|
|
546
|
+
fieldGroup,
|
|
547
|
+
path,
|
|
548
|
+
incrementalDataRecord
|
|
549
|
+
);
|
|
550
|
+
return null;
|
|
328
551
|
}
|
|
329
552
|
);
|
|
330
553
|
}
|
|
@@ -334,53 +557,37 @@ function executeField(exeContext, parentTypeName, source, fieldNodes, path) {
|
|
|
334
557
|
return completed;
|
|
335
558
|
} catch (rawError) {
|
|
336
559
|
const pathArray = (0, import_Path.pathToArray)(path);
|
|
337
|
-
const error = (0, import_graphql.locatedError)(
|
|
338
|
-
rawError,
|
|
339
|
-
fieldNodes,
|
|
340
|
-
pathArray
|
|
341
|
-
);
|
|
560
|
+
const error = (0, import_graphql.locatedError)(rawError, fieldGroup, pathArray);
|
|
342
561
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve) && error.path && (0, import_array.arraysAreEqual)(pathArray, error.path)) {
|
|
343
562
|
invokeAfterFieldResolveHook(info, exeContext, void 0, error);
|
|
344
563
|
}
|
|
345
564
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
346
565
|
invokeAfterFieldCompleteHook(info, exeContext, void 0, error);
|
|
347
566
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
returnTypeNode,
|
|
358
|
-
path,
|
|
359
|
-
fragments: exeContext.fragments,
|
|
360
|
-
rootValue: exeContext.rootValue,
|
|
361
|
-
operation: exeContext.operation,
|
|
362
|
-
variableValues: exeContext.variableValues
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
function handleFieldError(error, returnTypeNode, exeContext) {
|
|
366
|
-
if (returnTypeNode.kind === import_graphql.Kind.NON_NULL_TYPE) {
|
|
367
|
-
throw error;
|
|
567
|
+
handleFieldError(
|
|
568
|
+
rawError,
|
|
569
|
+
exeContext,
|
|
570
|
+
returnTypeRef,
|
|
571
|
+
fieldGroup,
|
|
572
|
+
path,
|
|
573
|
+
incrementalDataRecord
|
|
574
|
+
);
|
|
575
|
+
return null;
|
|
368
576
|
}
|
|
369
|
-
exeContext.errors.push(error);
|
|
370
|
-
return null;
|
|
371
577
|
}
|
|
372
|
-
function completeValue(exeContext,
|
|
578
|
+
function completeValue(exeContext, returnTypeRef, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
373
579
|
if (result instanceof Error) {
|
|
374
580
|
throw result;
|
|
375
581
|
}
|
|
376
|
-
if (
|
|
582
|
+
if ((0, import_reference.isNonNullType)(returnTypeRef)) {
|
|
377
583
|
const completed = completeValue(
|
|
378
584
|
exeContext,
|
|
379
|
-
|
|
380
|
-
|
|
585
|
+
(0, import_reference.unwrap)(returnTypeRef),
|
|
586
|
+
fieldGroup,
|
|
381
587
|
info,
|
|
382
588
|
path,
|
|
383
|
-
result
|
|
589
|
+
result,
|
|
590
|
+
incrementalDataRecord
|
|
384
591
|
);
|
|
385
592
|
if (completed === null) {
|
|
386
593
|
throw new Error(
|
|
@@ -392,105 +599,273 @@ function completeValue(exeContext, returnTypeNode, fieldNodes, info, path, resul
|
|
|
392
599
|
if (result == null) {
|
|
393
600
|
return null;
|
|
394
601
|
}
|
|
395
|
-
if (
|
|
602
|
+
if ((0, import_reference.isListType)(returnTypeRef)) {
|
|
396
603
|
return completeListValue(
|
|
397
604
|
exeContext,
|
|
398
|
-
|
|
399
|
-
|
|
605
|
+
returnTypeRef,
|
|
606
|
+
fieldGroup,
|
|
400
607
|
info,
|
|
401
608
|
path,
|
|
402
|
-
result
|
|
609
|
+
result,
|
|
610
|
+
incrementalDataRecord
|
|
403
611
|
);
|
|
404
612
|
}
|
|
405
|
-
const
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
if ((0, import_graphql.isLeafType)(returnType)) {
|
|
411
|
-
return completeLeafValue(returnType, result);
|
|
412
|
-
}
|
|
413
|
-
if (returnType instanceof import_graphql.GraphQLInputObjectType) {
|
|
613
|
+
const schemaTypes = exeContext.schemaTypes;
|
|
614
|
+
const returnTypeName = (0, import_reference.typeNameFromReference)(returnTypeRef);
|
|
615
|
+
const leafType = schemaTypes.getLeafTypeResolver(returnTypeRef);
|
|
616
|
+
if (leafType) {
|
|
617
|
+
return completeLeafValue(leafType, result);
|
|
414
618
|
}
|
|
415
|
-
if (
|
|
619
|
+
if (schemaTypes.isAbstractType(returnTypeRef)) {
|
|
416
620
|
return completeAbstractValue(
|
|
417
621
|
exeContext,
|
|
418
|
-
|
|
419
|
-
|
|
622
|
+
returnTypeName,
|
|
623
|
+
fieldGroup,
|
|
420
624
|
info,
|
|
421
625
|
path,
|
|
422
|
-
result
|
|
626
|
+
result,
|
|
627
|
+
incrementalDataRecord
|
|
423
628
|
);
|
|
424
629
|
}
|
|
425
|
-
if (
|
|
630
|
+
if (schemaTypes.isObjectType(returnTypeRef)) {
|
|
426
631
|
return completeObjectValue(
|
|
427
632
|
exeContext,
|
|
428
633
|
returnTypeName,
|
|
429
|
-
|
|
430
|
-
info,
|
|
634
|
+
fieldGroup,
|
|
431
635
|
path,
|
|
432
|
-
result
|
|
636
|
+
result,
|
|
637
|
+
incrementalDataRecord
|
|
433
638
|
);
|
|
434
639
|
}
|
|
435
640
|
(0, import_invariant.invariant)(
|
|
436
641
|
false,
|
|
437
|
-
"Cannot complete value of unexpected output type: " + (0,
|
|
642
|
+
"Cannot complete value of unexpected output type: " + (0, import_reference.inspectTypeReference)(returnTypeRef)
|
|
438
643
|
);
|
|
439
644
|
}
|
|
440
|
-
function
|
|
645
|
+
function completePromisedValue(exeContext, returnTypeRef, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
646
|
+
return __async(this, null, function* () {
|
|
647
|
+
try {
|
|
648
|
+
const resolved = yield result;
|
|
649
|
+
let completed = completeValue(
|
|
650
|
+
exeContext,
|
|
651
|
+
returnTypeRef,
|
|
652
|
+
fieldGroup,
|
|
653
|
+
info,
|
|
654
|
+
path,
|
|
655
|
+
resolved,
|
|
656
|
+
incrementalDataRecord
|
|
657
|
+
);
|
|
658
|
+
if ((0, import_isPromise.isPromise)(completed)) {
|
|
659
|
+
completed = yield completed;
|
|
660
|
+
}
|
|
661
|
+
return completed;
|
|
662
|
+
} catch (rawError) {
|
|
663
|
+
handleFieldError(
|
|
664
|
+
rawError,
|
|
665
|
+
exeContext,
|
|
666
|
+
returnTypeRef,
|
|
667
|
+
fieldGroup,
|
|
668
|
+
path,
|
|
669
|
+
incrementalDataRecord
|
|
670
|
+
);
|
|
671
|
+
filterSubsequentPayloads(exeContext, path, incrementalDataRecord);
|
|
672
|
+
return null;
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
function completeListValue(exeContext, returnTypeRef, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
677
|
+
const itemTypeRef = (0, import_reference.unwrap)(returnTypeRef);
|
|
678
|
+
if ((0, import_isAsyncIterable.isAsyncIterable)(result)) {
|
|
679
|
+
const asyncIterator = result[Symbol.asyncIterator]();
|
|
680
|
+
return completeAsyncIteratorValue(
|
|
681
|
+
exeContext,
|
|
682
|
+
itemTypeRef,
|
|
683
|
+
fieldGroup,
|
|
684
|
+
info,
|
|
685
|
+
path,
|
|
686
|
+
asyncIterator,
|
|
687
|
+
incrementalDataRecord
|
|
688
|
+
);
|
|
689
|
+
}
|
|
441
690
|
if (!(0, import_isIterableObject.isIterableObject)(result)) {
|
|
442
691
|
throw new import_graphql.GraphQLError(
|
|
443
692
|
`Expected Iterable, but did not find one for field "${info.parentTypeName}.${info.fieldName}".`
|
|
444
693
|
);
|
|
445
694
|
}
|
|
695
|
+
const stream = getStreamValues(exeContext, fieldGroup, path);
|
|
446
696
|
let containsPromise = false;
|
|
447
|
-
|
|
697
|
+
let previousIncrementalDataRecord = incrementalDataRecord;
|
|
698
|
+
const completedResults = [];
|
|
699
|
+
let index = 0;
|
|
700
|
+
for (const item of result) {
|
|
448
701
|
const itemPath = (0, import_Path.addPath)(path, index, void 0);
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
702
|
+
if (stream && typeof stream.initialCount === "number" && index >= stream.initialCount) {
|
|
703
|
+
previousIncrementalDataRecord = executeStreamField(
|
|
704
|
+
path,
|
|
705
|
+
itemPath,
|
|
706
|
+
item,
|
|
707
|
+
exeContext,
|
|
708
|
+
fieldGroup,
|
|
709
|
+
info,
|
|
710
|
+
itemTypeRef,
|
|
711
|
+
stream.label,
|
|
712
|
+
previousIncrementalDataRecord
|
|
713
|
+
);
|
|
714
|
+
index++;
|
|
715
|
+
continue;
|
|
716
|
+
}
|
|
717
|
+
if (completeListItemValue(
|
|
718
|
+
item,
|
|
719
|
+
completedResults,
|
|
720
|
+
exeContext,
|
|
721
|
+
itemTypeRef,
|
|
722
|
+
fieldGroup,
|
|
723
|
+
info,
|
|
724
|
+
itemPath,
|
|
725
|
+
incrementalDataRecord
|
|
726
|
+
)) {
|
|
727
|
+
containsPromise = true;
|
|
728
|
+
}
|
|
729
|
+
index++;
|
|
730
|
+
}
|
|
731
|
+
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
732
|
+
}
|
|
733
|
+
function completeListItemValue(item, completedResults, exeContext, itemTypeRef, fieldGroup, info, itemPath, incrementalDataRecord) {
|
|
734
|
+
if ((0, import_isPromise.isPromise)(item)) {
|
|
735
|
+
completedResults.push(
|
|
736
|
+
completePromisedValue(
|
|
737
|
+
exeContext,
|
|
738
|
+
itemTypeRef,
|
|
739
|
+
fieldGroup,
|
|
740
|
+
info,
|
|
741
|
+
itemPath,
|
|
742
|
+
item,
|
|
743
|
+
incrementalDataRecord
|
|
744
|
+
)
|
|
745
|
+
);
|
|
746
|
+
return true;
|
|
747
|
+
}
|
|
748
|
+
try {
|
|
749
|
+
const completedItem = completeValue(
|
|
750
|
+
exeContext,
|
|
751
|
+
itemTypeRef,
|
|
752
|
+
fieldGroup,
|
|
753
|
+
info,
|
|
754
|
+
itemPath,
|
|
755
|
+
item,
|
|
756
|
+
incrementalDataRecord
|
|
757
|
+
);
|
|
758
|
+
if ((0, import_isPromise.isPromise)(completedItem)) {
|
|
759
|
+
completedResults.push(
|
|
760
|
+
completedItem.then(void 0, (rawError) => {
|
|
761
|
+
handleFieldError(
|
|
762
|
+
rawError,
|
|
454
763
|
exeContext,
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
info,
|
|
764
|
+
itemTypeRef,
|
|
765
|
+
fieldGroup,
|
|
458
766
|
itemPath,
|
|
459
|
-
|
|
460
|
-
)
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
767
|
+
incrementalDataRecord
|
|
768
|
+
);
|
|
769
|
+
filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);
|
|
770
|
+
return null;
|
|
771
|
+
})
|
|
772
|
+
);
|
|
773
|
+
return true;
|
|
774
|
+
}
|
|
775
|
+
completedResults.push(completedItem);
|
|
776
|
+
} catch (rawError) {
|
|
777
|
+
handleFieldError(
|
|
778
|
+
rawError,
|
|
779
|
+
exeContext,
|
|
780
|
+
itemTypeRef,
|
|
781
|
+
fieldGroup,
|
|
782
|
+
itemPath,
|
|
783
|
+
incrementalDataRecord
|
|
784
|
+
);
|
|
785
|
+
filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);
|
|
786
|
+
completedResults.push(null);
|
|
787
|
+
}
|
|
788
|
+
return false;
|
|
789
|
+
}
|
|
790
|
+
function getStreamValues(exeContext, fieldGroup, path) {
|
|
791
|
+
if (typeof path.key === "number") {
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
const stream = (0, import_values.getDirectiveValues)(
|
|
795
|
+
exeContext,
|
|
796
|
+
import_directives.GraphQLStreamDirective,
|
|
797
|
+
fieldGroup[0]
|
|
798
|
+
);
|
|
799
|
+
if (!stream) {
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
if (stream.if === false) {
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
(0, import_invariant.invariant)(
|
|
806
|
+
typeof stream.initialCount === "number",
|
|
807
|
+
"initialCount must be a number"
|
|
808
|
+
);
|
|
809
|
+
(0, import_invariant.invariant)(
|
|
810
|
+
stream.initialCount >= 0,
|
|
811
|
+
"initialCount must be a positive integer"
|
|
812
|
+
);
|
|
813
|
+
(0, import_invariant.invariant)(
|
|
814
|
+
exeContext.operation.operation !== import_graphql.OperationTypeNode.SUBSCRIPTION,
|
|
815
|
+
"`@stream` directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`."
|
|
816
|
+
);
|
|
817
|
+
return {
|
|
818
|
+
initialCount: stream.initialCount,
|
|
819
|
+
label: typeof stream.label === "string" ? stream.label : void 0
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
function completeAsyncIteratorValue(exeContext, itemTypeRef, fieldGroup, info, path, asyncIterator, incrementalDataRecord) {
|
|
823
|
+
return __async(this, null, function* () {
|
|
824
|
+
const stream = getStreamValues(exeContext, fieldGroup, path);
|
|
825
|
+
let containsPromise = false;
|
|
826
|
+
const completedResults = [];
|
|
827
|
+
let index = 0;
|
|
828
|
+
while (true) {
|
|
829
|
+
if (stream && typeof stream.initialCount === "number" && index >= stream.initialCount) {
|
|
830
|
+
executeStreamAsyncIterator(
|
|
831
|
+
index,
|
|
832
|
+
asyncIterator,
|
|
464
833
|
exeContext,
|
|
465
|
-
|
|
466
|
-
fieldNodes,
|
|
834
|
+
fieldGroup,
|
|
467
835
|
info,
|
|
468
|
-
|
|
469
|
-
|
|
836
|
+
itemTypeRef,
|
|
837
|
+
path,
|
|
838
|
+
stream.label,
|
|
839
|
+
incrementalDataRecord
|
|
470
840
|
);
|
|
841
|
+
break;
|
|
471
842
|
}
|
|
472
|
-
|
|
843
|
+
const itemPath = (0, import_Path.addPath)(path, index, void 0);
|
|
844
|
+
let iteration;
|
|
845
|
+
try {
|
|
846
|
+
iteration = yield asyncIterator.next();
|
|
847
|
+
if (iteration.done) {
|
|
848
|
+
break;
|
|
849
|
+
}
|
|
850
|
+
} catch (rawError) {
|
|
851
|
+
throw (0, import_graphql.locatedError)(rawError, fieldGroup, (0, import_Path.pathToArray)(path));
|
|
852
|
+
}
|
|
853
|
+
if (completeListItemValue(
|
|
854
|
+
iteration.value,
|
|
855
|
+
completedResults,
|
|
856
|
+
exeContext,
|
|
857
|
+
itemTypeRef,
|
|
858
|
+
fieldGroup,
|
|
859
|
+
info,
|
|
860
|
+
itemPath,
|
|
861
|
+
incrementalDataRecord
|
|
862
|
+
)) {
|
|
473
863
|
containsPromise = true;
|
|
474
|
-
return completedItem.then(void 0, (rawError) => {
|
|
475
|
-
const error = (0, import_graphql.locatedError)(
|
|
476
|
-
rawError,
|
|
477
|
-
fieldNodes,
|
|
478
|
-
(0, import_Path.pathToArray)(itemPath)
|
|
479
|
-
);
|
|
480
|
-
return handleFieldError(error, returnTypeNode, exeContext);
|
|
481
|
-
});
|
|
482
864
|
}
|
|
483
|
-
|
|
484
|
-
} catch (rawError) {
|
|
485
|
-
const error = (0, import_graphql.locatedError)(
|
|
486
|
-
rawError,
|
|
487
|
-
fieldNodes,
|
|
488
|
-
(0, import_Path.pathToArray)(itemPath)
|
|
489
|
-
);
|
|
490
|
-
return handleFieldError(error, returnTypeNode, exeContext);
|
|
865
|
+
index += 1;
|
|
491
866
|
}
|
|
867
|
+
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
492
868
|
});
|
|
493
|
-
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
494
869
|
}
|
|
495
870
|
function completeLeafValue(returnType, result) {
|
|
496
871
|
const serializedResult = returnType.serialize(result);
|
|
@@ -501,93 +876,123 @@ function completeLeafValue(returnType, result) {
|
|
|
501
876
|
}
|
|
502
877
|
return serializedResult;
|
|
503
878
|
}
|
|
504
|
-
function completeAbstractValue(exeContext,
|
|
879
|
+
function completeAbstractValue(exeContext, returnTypeName, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
505
880
|
var _a;
|
|
506
|
-
const resolveTypeFn = (_a =
|
|
881
|
+
const resolveTypeFn = (_a = exeContext.schemaTypes.getAbstractTypeResolver(returnTypeName)) != null ? _a : exeContext.typeResolver;
|
|
507
882
|
const contextValue = exeContext.contextValue;
|
|
508
883
|
const runtimeTypeName = resolveTypeFn(result, contextValue, info);
|
|
509
884
|
if ((0, import_isPromise.isPromise)(runtimeTypeName)) {
|
|
510
885
|
return runtimeTypeName.then(
|
|
511
886
|
(resolvedRuntimeTypeName) => completeObjectValue(
|
|
512
887
|
exeContext,
|
|
513
|
-
ensureValidRuntimeType(
|
|
514
|
-
|
|
515
|
-
|
|
888
|
+
ensureValidRuntimeType(
|
|
889
|
+
resolvedRuntimeTypeName,
|
|
890
|
+
exeContext,
|
|
891
|
+
returnTypeName,
|
|
892
|
+
fieldGroup,
|
|
893
|
+
info,
|
|
894
|
+
result
|
|
895
|
+
),
|
|
896
|
+
fieldGroup,
|
|
516
897
|
path,
|
|
517
|
-
result
|
|
898
|
+
result,
|
|
899
|
+
incrementalDataRecord
|
|
518
900
|
)
|
|
519
901
|
);
|
|
520
902
|
}
|
|
521
903
|
return completeObjectValue(
|
|
522
904
|
exeContext,
|
|
523
|
-
ensureValidRuntimeType(
|
|
524
|
-
|
|
525
|
-
|
|
905
|
+
ensureValidRuntimeType(
|
|
906
|
+
runtimeTypeName,
|
|
907
|
+
exeContext,
|
|
908
|
+
returnTypeName,
|
|
909
|
+
fieldGroup,
|
|
910
|
+
info,
|
|
911
|
+
result
|
|
912
|
+
),
|
|
913
|
+
fieldGroup,
|
|
526
914
|
path,
|
|
527
|
-
result
|
|
915
|
+
result,
|
|
916
|
+
incrementalDataRecord
|
|
528
917
|
);
|
|
529
918
|
}
|
|
530
|
-
function ensureValidRuntimeType(runtimeTypeName, exeContext) {
|
|
531
|
-
if (
|
|
919
|
+
function ensureValidRuntimeType(runtimeTypeName, exeContext, returnTypeName, fieldGroup, info, result) {
|
|
920
|
+
if (runtimeTypeName == null) {
|
|
532
921
|
throw new import_graphql.GraphQLError(
|
|
533
|
-
`
|
|
922
|
+
`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.`,
|
|
923
|
+
{ nodes: fieldGroup }
|
|
534
924
|
);
|
|
535
925
|
}
|
|
536
|
-
|
|
537
|
-
if (!runtimeType) {
|
|
538
|
-
throw new import_graphql.GraphQLError(
|
|
539
|
-
`Type "${runtimeTypeName}" does not exist inside the schema.`
|
|
540
|
-
);
|
|
541
|
-
} else if (runtimeType instanceof import_graphql.GraphQLScalarType || runtimeType instanceof import_graphql.GraphQLEnumType || runtimeType instanceof import_graphql.GraphQLInputObjectType || runtimeType.__resolveType) {
|
|
926
|
+
if (typeof runtimeTypeName !== "string") {
|
|
542
927
|
throw new import_graphql.GraphQLError(
|
|
543
|
-
`
|
|
544
|
-
runtimeType
|
|
545
|
-
)}" type is not a possible type for "${runtimeTypeName}".`
|
|
928
|
+
`Abstract type "${returnTypeName}" must resolve to an Object type at runtime for field "${info.returnTypeName}.${info.fieldName}" with value ${(0, import_inspect.inspect)(result)}, received "${(0, import_inspect.inspect)(runtimeTypeName)}".`
|
|
546
929
|
);
|
|
930
|
+
}
|
|
931
|
+
const schemaTypes = exeContext.schemaTypes;
|
|
932
|
+
const iface = schemaTypes.getInterfaceType(returnTypeName);
|
|
933
|
+
if (iface) {
|
|
934
|
+
if (schemaTypes.isDefined(runtimeTypeName) && !schemaTypes.isObjectType(runtimeTypeName)) {
|
|
935
|
+
throw new import_graphql.GraphQLError(
|
|
936
|
+
`Abstract type "${returnTypeName}" was resolved to a non-object type "${runtimeTypeName}".`,
|
|
937
|
+
{ nodes: fieldGroup }
|
|
938
|
+
);
|
|
939
|
+
}
|
|
940
|
+
schemaTypes.addInterfaceImplementation(returnTypeName, runtimeTypeName);
|
|
547
941
|
} else {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
942
|
+
if (!schemaTypes.isDefined(runtimeTypeName)) {
|
|
943
|
+
throw new import_graphql.GraphQLError(
|
|
944
|
+
`Abstract type "${returnTypeName}" was resolved to a type "${runtimeTypeName}" that does not exist inside the schema.`,
|
|
945
|
+
{ nodes: fieldGroup }
|
|
946
|
+
);
|
|
947
|
+
}
|
|
948
|
+
if (!schemaTypes.isObjectType(runtimeTypeName)) {
|
|
949
|
+
throw new import_graphql.GraphQLError(
|
|
950
|
+
`Abstract type "${returnTypeName}" was resolved to a non-object type "${runtimeTypeName}".`,
|
|
951
|
+
{ nodes: fieldGroup }
|
|
952
|
+
);
|
|
953
|
+
}
|
|
954
|
+
if (!exeContext.schemaTypes.isSubType(returnTypeName, runtimeTypeName)) {
|
|
955
|
+
throw new import_graphql.GraphQLError(
|
|
956
|
+
`Runtime Object type "${runtimeTypeName}" is not a possible type for "${returnTypeName}".`,
|
|
957
|
+
{ nodes: fieldGroup }
|
|
958
|
+
);
|
|
959
|
+
}
|
|
564
960
|
}
|
|
961
|
+
return runtimeTypeName;
|
|
962
|
+
}
|
|
963
|
+
function completeObjectValue(exeContext, returnTypeName, fieldGroup, path, result, incrementalDataRecord) {
|
|
964
|
+
return collectAndExecuteSubfields(
|
|
965
|
+
exeContext,
|
|
966
|
+
returnTypeName,
|
|
967
|
+
fieldGroup,
|
|
968
|
+
path,
|
|
969
|
+
result,
|
|
970
|
+
incrementalDataRecord
|
|
971
|
+
);
|
|
565
972
|
}
|
|
566
|
-
function
|
|
567
|
-
const
|
|
973
|
+
function collectAndExecuteSubfields(exeContext, returnTypeName, fieldGroup, path, result, incrementalDataRecord) {
|
|
974
|
+
const { groupedFieldSet: subGroupedFieldSet, patches: subPatches } = collectSubfields(exeContext, { name: returnTypeName }, fieldGroup);
|
|
975
|
+
const subFields = executeFields(
|
|
568
976
|
exeContext,
|
|
569
977
|
returnTypeName,
|
|
570
|
-
|
|
978
|
+
result,
|
|
979
|
+
path,
|
|
980
|
+
subGroupedFieldSet,
|
|
981
|
+
incrementalDataRecord
|
|
571
982
|
);
|
|
572
|
-
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
returnTypeName,
|
|
584
|
-
node.selectionSet,
|
|
585
|
-
subFieldNodes,
|
|
586
|
-
visitedFragmentNames
|
|
587
|
-
);
|
|
588
|
-
}
|
|
983
|
+
for (const subPatch of subPatches) {
|
|
984
|
+
const { label, groupedFieldSet: subPatchGroupedFieldSet } = subPatch;
|
|
985
|
+
executeDeferredFragment(
|
|
986
|
+
exeContext,
|
|
987
|
+
returnTypeName,
|
|
988
|
+
result,
|
|
989
|
+
subPatchGroupedFieldSet,
|
|
990
|
+
label,
|
|
991
|
+
path,
|
|
992
|
+
incrementalDataRecord
|
|
993
|
+
);
|
|
589
994
|
}
|
|
590
|
-
return
|
|
995
|
+
return subFields;
|
|
591
996
|
}
|
|
592
997
|
function invokeBeforeFieldResolveHook(resolveInfo, exeContext) {
|
|
593
998
|
var _a;
|
|
@@ -698,11 +1103,408 @@ const defaultFieldResolver = (
|
|
|
698
1103
|
);
|
|
699
1104
|
function getOperationRootTypeName(operation) {
|
|
700
1105
|
switch (operation.operation) {
|
|
701
|
-
case
|
|
1106
|
+
case import_graphql.OperationTypeNode.QUERY:
|
|
702
1107
|
return "Query";
|
|
703
|
-
case
|
|
1108
|
+
case import_graphql.OperationTypeNode.MUTATION:
|
|
704
1109
|
return "Mutation";
|
|
705
|
-
case
|
|
1110
|
+
case import_graphql.OperationTypeNode.SUBSCRIPTION:
|
|
706
1111
|
return "Subscription";
|
|
707
1112
|
}
|
|
708
1113
|
}
|
|
1114
|
+
function executeDeferredFragment(exeContext, parentTypeName, sourceValue, fields, label, path, parentContext) {
|
|
1115
|
+
const incrementalDataRecord = new DeferredFragmentRecord({
|
|
1116
|
+
label,
|
|
1117
|
+
path,
|
|
1118
|
+
parentContext,
|
|
1119
|
+
exeContext
|
|
1120
|
+
});
|
|
1121
|
+
let promiseOrData;
|
|
1122
|
+
try {
|
|
1123
|
+
promiseOrData = executeFields(
|
|
1124
|
+
exeContext,
|
|
1125
|
+
parentTypeName,
|
|
1126
|
+
sourceValue,
|
|
1127
|
+
path,
|
|
1128
|
+
fields,
|
|
1129
|
+
incrementalDataRecord
|
|
1130
|
+
);
|
|
1131
|
+
if ((0, import_isPromise.isPromise)(promiseOrData)) {
|
|
1132
|
+
promiseOrData = promiseOrData.then(null, (e) => {
|
|
1133
|
+
incrementalDataRecord.errors.push(e);
|
|
1134
|
+
return null;
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
} catch (e) {
|
|
1138
|
+
incrementalDataRecord.errors.push(e);
|
|
1139
|
+
promiseOrData = null;
|
|
1140
|
+
}
|
|
1141
|
+
incrementalDataRecord.addData(promiseOrData);
|
|
1142
|
+
}
|
|
1143
|
+
function executeStreamField(path, itemPath, item, exeContext, fieldGroup, info, itemTypeRef, label, parentContext) {
|
|
1144
|
+
const incrementalDataRecord = new StreamItemsRecord({
|
|
1145
|
+
label,
|
|
1146
|
+
path: itemPath,
|
|
1147
|
+
parentContext,
|
|
1148
|
+
exeContext
|
|
1149
|
+
});
|
|
1150
|
+
if ((0, import_isPromise.isPromise)(item)) {
|
|
1151
|
+
const completedItems = completePromisedValue(
|
|
1152
|
+
exeContext,
|
|
1153
|
+
itemTypeRef,
|
|
1154
|
+
fieldGroup,
|
|
1155
|
+
info,
|
|
1156
|
+
itemPath,
|
|
1157
|
+
item,
|
|
1158
|
+
incrementalDataRecord
|
|
1159
|
+
).then(
|
|
1160
|
+
(value) => [value],
|
|
1161
|
+
(error) => {
|
|
1162
|
+
incrementalDataRecord.errors.push(error);
|
|
1163
|
+
filterSubsequentPayloads(exeContext, path, incrementalDataRecord);
|
|
1164
|
+
return null;
|
|
1165
|
+
}
|
|
1166
|
+
);
|
|
1167
|
+
incrementalDataRecord.addItems(completedItems);
|
|
1168
|
+
return incrementalDataRecord;
|
|
1169
|
+
}
|
|
1170
|
+
let completedItem;
|
|
1171
|
+
try {
|
|
1172
|
+
try {
|
|
1173
|
+
completedItem = completeValue(
|
|
1174
|
+
exeContext,
|
|
1175
|
+
itemTypeRef,
|
|
1176
|
+
fieldGroup,
|
|
1177
|
+
info,
|
|
1178
|
+
itemPath,
|
|
1179
|
+
item,
|
|
1180
|
+
incrementalDataRecord
|
|
1181
|
+
);
|
|
1182
|
+
} catch (rawError) {
|
|
1183
|
+
handleFieldError(
|
|
1184
|
+
rawError,
|
|
1185
|
+
exeContext,
|
|
1186
|
+
itemTypeRef,
|
|
1187
|
+
fieldGroup,
|
|
1188
|
+
itemPath,
|
|
1189
|
+
incrementalDataRecord
|
|
1190
|
+
);
|
|
1191
|
+
completedItem = null;
|
|
1192
|
+
filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);
|
|
1193
|
+
}
|
|
1194
|
+
} catch (error) {
|
|
1195
|
+
incrementalDataRecord.errors.push(error);
|
|
1196
|
+
filterSubsequentPayloads(exeContext, path, incrementalDataRecord);
|
|
1197
|
+
incrementalDataRecord.addItems(null);
|
|
1198
|
+
return incrementalDataRecord;
|
|
1199
|
+
}
|
|
1200
|
+
if ((0, import_isPromise.isPromise)(completedItem)) {
|
|
1201
|
+
const completedItems = completedItem.then(void 0, (rawError) => {
|
|
1202
|
+
handleFieldError(
|
|
1203
|
+
rawError,
|
|
1204
|
+
exeContext,
|
|
1205
|
+
itemTypeRef,
|
|
1206
|
+
fieldGroup,
|
|
1207
|
+
itemPath,
|
|
1208
|
+
incrementalDataRecord
|
|
1209
|
+
);
|
|
1210
|
+
filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);
|
|
1211
|
+
return null;
|
|
1212
|
+
}).then(
|
|
1213
|
+
(value) => [value],
|
|
1214
|
+
(error) => {
|
|
1215
|
+
incrementalDataRecord.errors.push(error);
|
|
1216
|
+
filterSubsequentPayloads(exeContext, path, incrementalDataRecord);
|
|
1217
|
+
return null;
|
|
1218
|
+
}
|
|
1219
|
+
);
|
|
1220
|
+
incrementalDataRecord.addItems(completedItems);
|
|
1221
|
+
return incrementalDataRecord;
|
|
1222
|
+
}
|
|
1223
|
+
incrementalDataRecord.addItems([completedItem]);
|
|
1224
|
+
return incrementalDataRecord;
|
|
1225
|
+
}
|
|
1226
|
+
function executeStreamAsyncIteratorItem(asyncIterator, exeContext, fieldGroup, info, itemTypeRef, incrementalDataRecord, path, itemPath) {
|
|
1227
|
+
return __async(this, null, function* () {
|
|
1228
|
+
let item;
|
|
1229
|
+
try {
|
|
1230
|
+
const { value, done } = yield asyncIterator.next();
|
|
1231
|
+
if (done) {
|
|
1232
|
+
incrementalDataRecord.setIsCompletedAsyncIterator();
|
|
1233
|
+
return { done, value: void 0 };
|
|
1234
|
+
}
|
|
1235
|
+
item = value;
|
|
1236
|
+
} catch (rawError) {
|
|
1237
|
+
throw (0, import_graphql.locatedError)(rawError, fieldGroup, (0, import_Path.pathToArray)(path));
|
|
1238
|
+
}
|
|
1239
|
+
let completedItem;
|
|
1240
|
+
try {
|
|
1241
|
+
completedItem = completeValue(
|
|
1242
|
+
exeContext,
|
|
1243
|
+
itemTypeRef,
|
|
1244
|
+
fieldGroup,
|
|
1245
|
+
info,
|
|
1246
|
+
itemPath,
|
|
1247
|
+
item,
|
|
1248
|
+
incrementalDataRecord
|
|
1249
|
+
);
|
|
1250
|
+
if ((0, import_isPromise.isPromise)(completedItem)) {
|
|
1251
|
+
completedItem = completedItem.then(void 0, (rawError) => {
|
|
1252
|
+
handleFieldError(
|
|
1253
|
+
rawError,
|
|
1254
|
+
exeContext,
|
|
1255
|
+
itemTypeRef,
|
|
1256
|
+
fieldGroup,
|
|
1257
|
+
itemPath,
|
|
1258
|
+
incrementalDataRecord
|
|
1259
|
+
);
|
|
1260
|
+
filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);
|
|
1261
|
+
return null;
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1264
|
+
return { done: false, value: completedItem };
|
|
1265
|
+
} catch (rawError) {
|
|
1266
|
+
handleFieldError(
|
|
1267
|
+
rawError,
|
|
1268
|
+
exeContext,
|
|
1269
|
+
itemTypeRef,
|
|
1270
|
+
fieldGroup,
|
|
1271
|
+
itemPath,
|
|
1272
|
+
incrementalDataRecord
|
|
1273
|
+
);
|
|
1274
|
+
filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);
|
|
1275
|
+
return { done: false, value: null };
|
|
1276
|
+
}
|
|
1277
|
+
});
|
|
1278
|
+
}
|
|
1279
|
+
function executeStreamAsyncIterator(initialIndex, asyncIterator, exeContext, fieldGroup, info, itemTypeRef, path, label, parentContext) {
|
|
1280
|
+
return __async(this, null, function* () {
|
|
1281
|
+
let index = initialIndex;
|
|
1282
|
+
let previousIncrementalDataRecord = parentContext != null ? parentContext : void 0;
|
|
1283
|
+
while (true) {
|
|
1284
|
+
const itemPath = (0, import_Path.addPath)(path, index, void 0);
|
|
1285
|
+
const incrementalDataRecord = new StreamItemsRecord({
|
|
1286
|
+
label,
|
|
1287
|
+
path: itemPath,
|
|
1288
|
+
parentContext: previousIncrementalDataRecord,
|
|
1289
|
+
asyncIterator,
|
|
1290
|
+
exeContext
|
|
1291
|
+
});
|
|
1292
|
+
let iteration;
|
|
1293
|
+
try {
|
|
1294
|
+
iteration = yield executeStreamAsyncIteratorItem(
|
|
1295
|
+
asyncIterator,
|
|
1296
|
+
exeContext,
|
|
1297
|
+
fieldGroup,
|
|
1298
|
+
info,
|
|
1299
|
+
itemTypeRef,
|
|
1300
|
+
incrementalDataRecord,
|
|
1301
|
+
path,
|
|
1302
|
+
itemPath
|
|
1303
|
+
);
|
|
1304
|
+
} catch (error) {
|
|
1305
|
+
incrementalDataRecord.errors.push(error);
|
|
1306
|
+
filterSubsequentPayloads(exeContext, path, incrementalDataRecord);
|
|
1307
|
+
incrementalDataRecord.addItems(null);
|
|
1308
|
+
if (asyncIterator == null ? void 0 : asyncIterator.return) {
|
|
1309
|
+
asyncIterator.return().catch(() => {
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
const { done, value: completedItem } = iteration;
|
|
1315
|
+
let completedItems;
|
|
1316
|
+
if ((0, import_isPromise.isPromise)(completedItem)) {
|
|
1317
|
+
completedItems = completedItem.then(
|
|
1318
|
+
(value) => [value],
|
|
1319
|
+
(error) => {
|
|
1320
|
+
incrementalDataRecord.errors.push(error);
|
|
1321
|
+
filterSubsequentPayloads(exeContext, path, incrementalDataRecord);
|
|
1322
|
+
return null;
|
|
1323
|
+
}
|
|
1324
|
+
);
|
|
1325
|
+
} else {
|
|
1326
|
+
completedItems = [completedItem];
|
|
1327
|
+
}
|
|
1328
|
+
incrementalDataRecord.addItems(completedItems);
|
|
1329
|
+
if (done) {
|
|
1330
|
+
break;
|
|
1331
|
+
}
|
|
1332
|
+
previousIncrementalDataRecord = incrementalDataRecord;
|
|
1333
|
+
index++;
|
|
1334
|
+
}
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
function filterSubsequentPayloads(exeContext, nullPath, currentIncrementalDataRecord) {
|
|
1338
|
+
const nullPathArray = (0, import_Path.pathToArray)(nullPath);
|
|
1339
|
+
exeContext.subsequentPayloads.forEach((incrementalDataRecord) => {
|
|
1340
|
+
var _a;
|
|
1341
|
+
if (incrementalDataRecord === currentIncrementalDataRecord) {
|
|
1342
|
+
return;
|
|
1343
|
+
}
|
|
1344
|
+
for (let i = 0; i < nullPathArray.length; i++) {
|
|
1345
|
+
if (incrementalDataRecord.path[i] !== nullPathArray[i]) {
|
|
1346
|
+
return;
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
if (isStreamItemsRecord(incrementalDataRecord) && ((_a = incrementalDataRecord.asyncIterator) == null ? void 0 : _a.return)) {
|
|
1350
|
+
incrementalDataRecord.asyncIterator.return().catch(() => {
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
exeContext.subsequentPayloads.delete(incrementalDataRecord);
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1356
|
+
function getCompletedIncrementalResults(exeContext) {
|
|
1357
|
+
const incrementalResults = [];
|
|
1358
|
+
for (const incrementalDataRecord of exeContext.subsequentPayloads) {
|
|
1359
|
+
const incrementalResult = {};
|
|
1360
|
+
if (!incrementalDataRecord.isCompleted) {
|
|
1361
|
+
continue;
|
|
1362
|
+
}
|
|
1363
|
+
exeContext.subsequentPayloads.delete(incrementalDataRecord);
|
|
1364
|
+
if (isStreamItemsRecord(incrementalDataRecord)) {
|
|
1365
|
+
const items = incrementalDataRecord.items;
|
|
1366
|
+
if (incrementalDataRecord.isCompletedAsyncIterator) {
|
|
1367
|
+
continue;
|
|
1368
|
+
}
|
|
1369
|
+
incrementalResult.items = items;
|
|
1370
|
+
} else {
|
|
1371
|
+
const data = incrementalDataRecord.data;
|
|
1372
|
+
incrementalResult.data = data != null ? data : null;
|
|
1373
|
+
}
|
|
1374
|
+
incrementalResult.path = incrementalDataRecord.path;
|
|
1375
|
+
if (incrementalDataRecord.label != null) {
|
|
1376
|
+
incrementalResult.label = incrementalDataRecord.label;
|
|
1377
|
+
}
|
|
1378
|
+
if (incrementalDataRecord.errors.length > 0) {
|
|
1379
|
+
incrementalResult.errors = incrementalDataRecord.errors;
|
|
1380
|
+
}
|
|
1381
|
+
incrementalResults.push(incrementalResult);
|
|
1382
|
+
}
|
|
1383
|
+
return incrementalResults;
|
|
1384
|
+
}
|
|
1385
|
+
function yieldSubsequentPayloads(exeContext) {
|
|
1386
|
+
let isDone = false;
|
|
1387
|
+
function next() {
|
|
1388
|
+
return __async(this, null, function* () {
|
|
1389
|
+
if (isDone) {
|
|
1390
|
+
return { value: void 0, done: true };
|
|
1391
|
+
}
|
|
1392
|
+
yield Promise.race(
|
|
1393
|
+
Array.from(exeContext.subsequentPayloads).map((p) => p.promise)
|
|
1394
|
+
);
|
|
1395
|
+
if (isDone) {
|
|
1396
|
+
return { value: void 0, done: true };
|
|
1397
|
+
}
|
|
1398
|
+
const incremental = getCompletedIncrementalResults(exeContext);
|
|
1399
|
+
const hasNext = exeContext.subsequentPayloads.size > 0;
|
|
1400
|
+
if (!incremental.length && hasNext) {
|
|
1401
|
+
return next();
|
|
1402
|
+
}
|
|
1403
|
+
if (!hasNext) {
|
|
1404
|
+
isDone = true;
|
|
1405
|
+
}
|
|
1406
|
+
return {
|
|
1407
|
+
value: incremental.length ? { incremental, hasNext } : { hasNext },
|
|
1408
|
+
done: false
|
|
1409
|
+
};
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
function returnStreamIterators() {
|
|
1413
|
+
const promises = [];
|
|
1414
|
+
exeContext.subsequentPayloads.forEach((incrementalDataRecord) => {
|
|
1415
|
+
var _a2;
|
|
1416
|
+
if (isStreamItemsRecord(incrementalDataRecord) && ((_a2 = incrementalDataRecord.asyncIterator) == null ? void 0 : _a2.return)) {
|
|
1417
|
+
promises.push(incrementalDataRecord.asyncIterator.return());
|
|
1418
|
+
}
|
|
1419
|
+
});
|
|
1420
|
+
return Promise.all(promises);
|
|
1421
|
+
}
|
|
1422
|
+
return {
|
|
1423
|
+
[Symbol.asyncIterator]() {
|
|
1424
|
+
return this;
|
|
1425
|
+
},
|
|
1426
|
+
next,
|
|
1427
|
+
return() {
|
|
1428
|
+
return __async(this, null, function* () {
|
|
1429
|
+
yield returnStreamIterators();
|
|
1430
|
+
isDone = true;
|
|
1431
|
+
return { value: void 0, done: true };
|
|
1432
|
+
});
|
|
1433
|
+
},
|
|
1434
|
+
throw(error) {
|
|
1435
|
+
return __async(this, null, function* () {
|
|
1436
|
+
yield returnStreamIterators();
|
|
1437
|
+
isDone = true;
|
|
1438
|
+
return Promise.reject(error);
|
|
1439
|
+
});
|
|
1440
|
+
}
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
function isStreamItemsRecord(incrementalDataRecord) {
|
|
1444
|
+
return incrementalDataRecord.type === "stream";
|
|
1445
|
+
}
|
|
1446
|
+
class DeferredFragmentRecord {
|
|
1447
|
+
constructor(opts) {
|
|
1448
|
+
this.type = "defer";
|
|
1449
|
+
this.label = opts.label;
|
|
1450
|
+
this.path = (0, import_Path.pathToArray)(opts.path);
|
|
1451
|
+
this.parentContext = opts.parentContext;
|
|
1452
|
+
this.errors = [];
|
|
1453
|
+
this._exeContext = opts.exeContext;
|
|
1454
|
+
this._exeContext.subsequentPayloads.add(this);
|
|
1455
|
+
this.isCompleted = false;
|
|
1456
|
+
this.data = null;
|
|
1457
|
+
this.promise = new Promise((resolve) => {
|
|
1458
|
+
this._resolve = (promiseOrValue) => {
|
|
1459
|
+
resolve(promiseOrValue);
|
|
1460
|
+
};
|
|
1461
|
+
}).then((data) => {
|
|
1462
|
+
this.data = data;
|
|
1463
|
+
this.isCompleted = true;
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
addData(data) {
|
|
1467
|
+
var _a, _b, _c;
|
|
1468
|
+
const parentData = (_a = this.parentContext) == null ? void 0 : _a.promise;
|
|
1469
|
+
if (parentData) {
|
|
1470
|
+
(_b = this._resolve) == null ? void 0 : _b.call(this, parentData.then(() => data));
|
|
1471
|
+
return;
|
|
1472
|
+
}
|
|
1473
|
+
(_c = this._resolve) == null ? void 0 : _c.call(this, data);
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
class StreamItemsRecord {
|
|
1477
|
+
constructor(opts) {
|
|
1478
|
+
this.type = "stream";
|
|
1479
|
+
this.items = null;
|
|
1480
|
+
this.label = opts.label;
|
|
1481
|
+
this.path = (0, import_Path.pathToArray)(opts.path);
|
|
1482
|
+
this.parentContext = opts.parentContext;
|
|
1483
|
+
this.asyncIterator = opts.asyncIterator;
|
|
1484
|
+
this.errors = [];
|
|
1485
|
+
this._exeContext = opts.exeContext;
|
|
1486
|
+
this._exeContext.subsequentPayloads.add(this);
|
|
1487
|
+
this.isCompleted = false;
|
|
1488
|
+
this.items = null;
|
|
1489
|
+
this.promise = new Promise((resolve) => {
|
|
1490
|
+
this._resolve = (promiseOrValue) => {
|
|
1491
|
+
resolve(promiseOrValue);
|
|
1492
|
+
};
|
|
1493
|
+
}).then((items) => {
|
|
1494
|
+
this.items = items;
|
|
1495
|
+
this.isCompleted = true;
|
|
1496
|
+
});
|
|
1497
|
+
}
|
|
1498
|
+
addItems(items) {
|
|
1499
|
+
var _a, _b, _c;
|
|
1500
|
+
const parentData = (_a = this.parentContext) == null ? void 0 : _a.promise;
|
|
1501
|
+
if (parentData) {
|
|
1502
|
+
(_b = this._resolve) == null ? void 0 : _b.call(this, parentData.then(() => items));
|
|
1503
|
+
return;
|
|
1504
|
+
}
|
|
1505
|
+
(_c = this._resolve) == null ? void 0 : _c.call(this, items);
|
|
1506
|
+
}
|
|
1507
|
+
setIsCompletedAsyncIterator() {
|
|
1508
|
+
this.isCompletedAsyncIterator = true;
|
|
1509
|
+
}
|
|
1510
|
+
}
|