@graphitation/supermassive 3.8.7 → 3.10.0
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 +2 -2
- package/lib/__testUtils__/execute.d.ts.map +1 -1
- package/lib/__testUtils__/execute.js +77 -119
- package/lib/__testUtils__/execute.js.map +2 -2
- package/lib/__testUtils__/execute.mjs +77 -122
- package/lib/__testUtils__/execute.mjs.map +2 -2
- package/lib/benchmarks/index.js +41 -63
- package/lib/benchmarks/index.js.map +1 -1
- package/lib/benchmarks/index.mjs +152 -184
- package/lib/benchmarks/index.mjs.map +1 -1
- package/lib/benchmarks/nice-benchmark.js +3 -23
- package/lib/benchmarks/nice-benchmark.js.map +1 -1
- package/lib/benchmarks/nice-benchmark.mjs +3 -24
- package/lib/benchmarks/nice-benchmark.mjs.map +1 -1
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.js +78 -68
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.js.map +1 -1
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.mjs +78 -71
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.mjs.map +1 -1
- package/lib/benchmarks/swapi-schema/resolvers.js +31 -71
- package/lib/benchmarks/swapi-schema/resolvers.js.map +1 -1
- package/lib/benchmarks/swapi-schema/resolvers.mjs +31 -74
- package/lib/benchmarks/swapi-schema/resolvers.mjs.map +1 -1
- package/lib/executeWithSchema.d.ts +1 -1
- package/lib/executeWithSchema.d.ts.map +1 -1
- package/lib/executeWithSchema.js +4 -2
- package/lib/executeWithSchema.js.map +2 -2
- package/lib/executeWithSchema.mjs +4 -2
- package/lib/executeWithSchema.mjs.map +2 -2
- package/lib/executeWithoutSchema.d.ts +1 -0
- package/lib/executeWithoutSchema.d.ts.map +1 -1
- package/lib/executeWithoutSchema.js +205 -252
- package/lib/executeWithoutSchema.js.map +2 -2
- package/lib/executeWithoutSchema.mjs +205 -255
- package/lib/executeWithoutSchema.mjs.map +2 -2
- package/lib/legacyAST/addTypesToRequestDocument.js +6 -21
- package/lib/legacyAST/addTypesToRequestDocument.js.map +1 -1
- package/lib/legacyAST/addTypesToRequestDocument.mjs +6 -24
- package/lib/legacyAST/addTypesToRequestDocument.mjs.map +1 -1
- package/lib/types.d.ts +1 -0
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.js +9 -23
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.js.map +1 -1
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.mjs +9 -26
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.mjs.map +1 -1
- package/lib/utilities/mapAsyncIterator.js +19 -47
- package/lib/utilities/mapAsyncIterator.js.map +1 -1
- package/lib/utilities/mapAsyncIterator.mjs +19 -48
- package/lib/utilities/mapAsyncIterator.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
# Change Log - @graphitation/supermassive
|
|
2
2
|
|
|
3
|
-
<!-- This log was last generated on
|
|
3
|
+
<!-- This log was last generated on Wed, 02 Apr 2025 11:41:54 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 3.10.0
|
|
8
|
+
|
|
9
|
+
Wed, 02 Apr 2025 11:41:54 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- Changed build target from ES6 to ES2018 (vrazuvaev@microsoft.com_msteamsmdb)
|
|
14
|
+
|
|
15
|
+
## 3.9.0
|
|
16
|
+
|
|
17
|
+
Fri, 28 Mar 2025 09:57:05 GMT
|
|
18
|
+
|
|
19
|
+
### Minor changes
|
|
20
|
+
|
|
21
|
+
- Returing back bug fix in event stream context (77059398+vejrj@users.noreply.github.com)
|
|
22
|
+
|
|
7
23
|
## 3.8.2
|
|
8
24
|
|
|
9
25
|
Thu, 23 Jan 2025 12:25:19 GMT
|
|
@@ -4,8 +4,8 @@ import { PromiseOrValue } from "graphql/jsutils/PromiseOrValue";
|
|
|
4
4
|
import { ObjMap } from "../jsutils/ObjMap";
|
|
5
5
|
type GraphQLResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> = GraphQLExecutionResult<TData, TExtensions> | AsyncGenerator<GraphQLExecutionResult<TData, TExtensions>, void, void>;
|
|
6
6
|
export declare function createExecutionUtils(graphqlExecute: (args: ExecutionArgs) => PromiseOrValue<ExecutionResult>, graphqlSubscribe: (args: ExecutionArgs) => PromiseOrValue<AsyncIterableIterator<ExecutionResult> | ExecutionResult>): {
|
|
7
|
-
compareResultForExecuteWithoutSchemaWithMVSAnnotation: (schema: GraphQLSchema, query: string, variables?: Record<string, unknown
|
|
8
|
-
compareResultsForExecuteWithSchema: (schema: GraphQLSchema, query: string, variables?: Record<string, unknown
|
|
7
|
+
compareResultForExecuteWithoutSchemaWithMVSAnnotation: (schema: GraphQLSchema, query: string, variables?: Record<string, unknown>, enablePerEventContext?: boolean) => Promise<void>;
|
|
8
|
+
compareResultsForExecuteWithSchema: (schema: GraphQLSchema, query: string, variables?: Record<string, unknown>, enablePerEventContext?: boolean) => Promise<void>;
|
|
9
9
|
drainExecution: (result: ExecutionResult | GraphQLResult) => Promise<unknown>;
|
|
10
10
|
graphqlExecuteOrSubscribe: (args: GraphQLExecutionArgs) => PromiseOrValue<GraphQLResult>;
|
|
11
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/__testUtils__/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EAIb,aAAa,EACb,aAAa,IAAI,oBAAoB,EACrC,eAAe,IAAI,sBAAsB,EAC1C,MAAM,SAAS,CAAC;AAIjB,OAAO,EAAE,eAAe,EAAiB,MAAM,UAAU,CAAC;AAI1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EACxE,gBAAgB,EAAE,CAChB,IAAI,EAAE,aAAa,KAChB,cAAc,CAAC,qBAAqB,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;oEAoCnE,aAAa,SACd,MAAM,cACF,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,0BACV,OAAO;iDApCvB,aAAa,SACd,MAAM,cACD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,0BACX,OAAO;6BAqGvB,eAAe,GAAG,aAAa,KACtC,OAAO,CAAC,OAAO,CAAC;sCAhCX,oBAAoB,KACzB,cAAc,CAAC,aAAa,CAAC;EA8DjC"}
|
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
10
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols)
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
8
|
var __export = (target, all) => {
|
|
26
9
|
for (var name in all)
|
|
27
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -43,26 +26,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
43
26
|
mod
|
|
44
27
|
));
|
|
45
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
46
|
-
var __async = (__this, __arguments, generator) => {
|
|
47
|
-
return new Promise((resolve, reject) => {
|
|
48
|
-
var fulfilled = (value) => {
|
|
49
|
-
try {
|
|
50
|
-
step(generator.next(value));
|
|
51
|
-
} catch (e) {
|
|
52
|
-
reject(e);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
var rejected = (value) => {
|
|
56
|
-
try {
|
|
57
|
-
step(generator.throw(value));
|
|
58
|
-
} catch (e) {
|
|
59
|
-
reject(e);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
63
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
29
|
var execute_exports = {};
|
|
67
30
|
__export(execute_exports, {
|
|
68
31
|
createExecutionUtils: () => createExecutionUtils
|
|
@@ -77,68 +40,66 @@ var import_executeWithoutSchema = require("../executeWithoutSchema");
|
|
|
77
40
|
var import_extractMinimalViableSchemaForRequestDocument = require("../utilities/extractMinimalViableSchemaForRequestDocument");
|
|
78
41
|
var import_iterall = require("iterall");
|
|
79
42
|
function createExecutionUtils(graphqlExecute, graphqlSubscribe) {
|
|
80
|
-
function compareResultsForExecuteWithSchema(schema, query, variables) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
});
|
|
43
|
+
async function compareResultsForExecuteWithSchema(schema, query, variables, enablePerEventContext) {
|
|
44
|
+
expect.assertions(1);
|
|
45
|
+
const document = (0, import_graphql.parse)(query);
|
|
46
|
+
const result = await drainExecution(
|
|
47
|
+
await (0, import_executeWithSchema.executeWithSchema)({
|
|
48
|
+
document,
|
|
49
|
+
definitions: import_swapi_schema.typeDefs,
|
|
50
|
+
resolvers: import_resolvers.default,
|
|
51
|
+
contextValue: {
|
|
52
|
+
models: import_models.default
|
|
53
|
+
},
|
|
54
|
+
variableValues: variables,
|
|
55
|
+
enablePerEventContext
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
|
+
const validResult = await drainExecution(
|
|
59
|
+
await graphqlExecuteOrSubscribe({
|
|
60
|
+
document,
|
|
61
|
+
contextValue: {
|
|
62
|
+
models: import_models.default
|
|
63
|
+
},
|
|
64
|
+
schema,
|
|
65
|
+
variableValues: variables
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
expect(result).toEqual(validResult);
|
|
107
69
|
}
|
|
108
|
-
function compareResultForExecuteWithoutSchemaWithMVSAnnotation(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
70
|
+
async function compareResultForExecuteWithoutSchemaWithMVSAnnotation(schema, query, variables = {}, enablePerEventContext) {
|
|
71
|
+
expect.assertions(1);
|
|
72
|
+
const document = (0, import_graphql.parse)(query);
|
|
73
|
+
const { definitions } = (0, import_extractMinimalViableSchemaForRequestDocument.extractMinimalViableSchemaForRequestDocument)(
|
|
74
|
+
schema,
|
|
75
|
+
document
|
|
76
|
+
);
|
|
77
|
+
const result = await drainExecution(
|
|
78
|
+
await (0, import_executeWithoutSchema.executeWithoutSchema)({
|
|
79
|
+
document,
|
|
80
|
+
contextValue: {
|
|
81
|
+
models: import_models.default
|
|
82
|
+
},
|
|
83
|
+
schemaFragment: {
|
|
84
|
+
schemaId: "test",
|
|
85
|
+
definitions,
|
|
86
|
+
resolvers: import_resolvers.default
|
|
87
|
+
},
|
|
88
|
+
variableValues: variables,
|
|
89
|
+
enablePerEventContext
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
const validResult = await drainExecution(
|
|
93
|
+
await graphqlExecuteOrSubscribe({
|
|
94
|
+
document,
|
|
95
|
+
contextValue: {
|
|
96
|
+
models: import_models.default
|
|
97
|
+
},
|
|
113
98
|
schema,
|
|
114
|
-
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
document,
|
|
119
|
-
contextValue: {
|
|
120
|
-
models: import_models.default
|
|
121
|
-
},
|
|
122
|
-
schemaFragment: {
|
|
123
|
-
schemaId: "test",
|
|
124
|
-
definitions,
|
|
125
|
-
resolvers: import_resolvers.default
|
|
126
|
-
},
|
|
127
|
-
variableValues: variables
|
|
128
|
-
})
|
|
129
|
-
);
|
|
130
|
-
const validResult = yield drainExecution(
|
|
131
|
-
yield graphqlExecuteOrSubscribe({
|
|
132
|
-
document,
|
|
133
|
-
contextValue: {
|
|
134
|
-
models: import_models.default
|
|
135
|
-
},
|
|
136
|
-
schema,
|
|
137
|
-
variableValues: variables
|
|
138
|
-
})
|
|
139
|
-
);
|
|
140
|
-
expect(result).toEqual(validResult);
|
|
141
|
-
});
|
|
99
|
+
variableValues: variables
|
|
100
|
+
})
|
|
101
|
+
);
|
|
102
|
+
expect(result).toEqual(validResult);
|
|
142
103
|
}
|
|
143
104
|
function graphqlExecuteOrSubscribe(args) {
|
|
144
105
|
var _a;
|
|
@@ -167,29 +128,26 @@ function createExecutionUtils(graphqlExecute, graphqlSubscribe) {
|
|
|
167
128
|
return graphqlExecute(args);
|
|
168
129
|
}
|
|
169
130
|
}
|
|
170
|
-
function drainExecution(result) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
});
|
|
131
|
+
async function drainExecution(result) {
|
|
132
|
+
let processedResult;
|
|
133
|
+
if ((0, import_iterall.isAsyncIterable)(result)) {
|
|
134
|
+
processedResult = await drainAsyncGeneratorToArray(result);
|
|
135
|
+
} else if ("subsequentResults" in result) {
|
|
136
|
+
processedResult = {
|
|
137
|
+
...result,
|
|
138
|
+
subsequentResults: await drainAsyncGeneratorToArray(
|
|
139
|
+
result.subsequentResults
|
|
140
|
+
)
|
|
141
|
+
};
|
|
142
|
+
} else {
|
|
143
|
+
processedResult = result;
|
|
144
|
+
}
|
|
145
|
+
return processedResult;
|
|
186
146
|
}
|
|
187
|
-
function drainAsyncGeneratorToArray(collection) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
return result;
|
|
192
|
-
});
|
|
147
|
+
async function drainAsyncGeneratorToArray(collection) {
|
|
148
|
+
const result = [];
|
|
149
|
+
await (0, import_iterall.forAwaitEach)(collection, (item) => result.push(item));
|
|
150
|
+
return result;
|
|
193
151
|
}
|
|
194
152
|
return {
|
|
195
153
|
compareResultForExecuteWithoutSchemaWithMVSAnnotation,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/__testUtils__/execute.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n DocumentNode,\n GraphQLSchema,\n Kind,\n OperationDefinitionNode,\n parse,\n ExecutionArgs,\n ExecutionArgs as GraphQLExecutionArgs,\n ExecutionResult as GraphQLExecutionResult,\n} from \"graphql\";\nimport { executeWithSchema } from \"../executeWithSchema\";\nimport { typeDefs } from \"../benchmarks/swapi-schema\";\nimport resolvers from \"../benchmarks/swapi-schema/resolvers\";\nimport { ExecutionResult, UserResolvers } from \"../types\";\nimport models from \"../benchmarks/swapi-schema/models\";\nimport { executeWithoutSchema } from \"../executeWithoutSchema\";\nimport { extractMinimalViableSchemaForRequestDocument } from \"../utilities/extractMinimalViableSchemaForRequestDocument\";\nimport { PromiseOrValue } from \"graphql/jsutils/PromiseOrValue\";\nimport { ObjMap } from \"../jsutils/ObjMap\";\nimport { forAwaitEach, isAsyncIterable } from \"iterall\";\n\ntype GraphQLResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> =\n | GraphQLExecutionResult<TData, TExtensions>\n | AsyncGenerator<GraphQLExecutionResult<TData, TExtensions>, void, void>;\n\nexport function createExecutionUtils(\n graphqlExecute: (args: ExecutionArgs) => PromiseOrValue<ExecutionResult>,\n graphqlSubscribe: (\n args: ExecutionArgs,\n ) => PromiseOrValue<AsyncIterableIterator<ExecutionResult> | ExecutionResult>,\n) {\n async function compareResultsForExecuteWithSchema(\n schema: GraphQLSchema,\n query: string,\n variables?: Record<string, unknown>,\n ) {\n expect.assertions(1);\n const document = parse(query);\n const result = await drainExecution(\n await executeWithSchema({\n document,\n definitions: typeDefs,\n resolvers: resolvers as UserResolvers<unknown, unknown>,\n contextValue: {\n models,\n },\n variableValues: variables,\n }),\n );\n const validResult = await drainExecution(\n await graphqlExecuteOrSubscribe({\n document,\n contextValue: {\n models,\n },\n schema,\n variableValues: variables,\n }),\n );\n expect(result).toEqual(validResult);\n }\n\n async function compareResultForExecuteWithoutSchemaWithMVSAnnotation(\n schema: GraphQLSchema,\n query: string,\n variables: Record<string, unknown> = {},\n ) {\n expect.assertions(1);\n const document = parse(query);\n const { definitions } = extractMinimalViableSchemaForRequestDocument(\n schema,\n document,\n );\n const result = await drainExecution(\n await executeWithoutSchema({\n document,\n contextValue: {\n models,\n },\n schemaFragment: {\n schemaId: \"test\",\n definitions,\n resolvers: resolvers as UserResolvers,\n },\n variableValues: variables,\n }),\n );\n const validResult = await drainExecution(\n await graphqlExecuteOrSubscribe({\n document,\n contextValue: {\n models,\n },\n schema,\n variableValues: variables,\n }),\n );\n expect(result).toEqual(validResult);\n }\n\n function graphqlExecuteOrSubscribe(\n args: GraphQLExecutionArgs,\n ): PromiseOrValue<GraphQLResult> {\n const operationName = args.operationName;\n let operation: OperationDefinitionNode | undefined;\n for (const definition of (args.document as unknown as DocumentNode)\n .definitions) {\n switch (definition.kind) {\n case Kind.OPERATION_DEFINITION:\n if (operationName == null) {\n if (operation !== undefined) {\n throw new Error(\"Bad operation in test\");\n }\n operation = definition;\n } else if (definition.name?.value === operationName) {\n operation = definition;\n }\n break;\n }\n }\n if (!operation) {\n throw new Error(\"Bad operation in test\");\n }\n\n if (operation.operation === \"subscription\") {\n return graphqlSubscribe(args) as GraphQLResult;\n } else {\n return graphqlExecute(args) as GraphQLResult;\n }\n }\n\n async function drainExecution(\n result: ExecutionResult | GraphQLResult,\n ): Promise<unknown> {\n let processedResult;\n if (isAsyncIterable(result)) {\n processedResult = await drainAsyncGeneratorToArray(result);\n } else if (\"subsequentResults\" in result) {\n processedResult = {\n ...result,\n subsequentResults: await drainAsyncGeneratorToArray(\n result.subsequentResults,\n ),\n };\n } else {\n processedResult = result;\n }\n return processedResult;\n }\n\n async function drainAsyncGeneratorToArray<T>(\n collection: AsyncGenerator<T, void, void>,\n ): Promise<T[]> {\n const result: T[] = [];\n await forAwaitEach(collection, (item) => result.push(item));\n return result;\n }\n\n return {\n compareResultForExecuteWithoutSchemaWithMVSAnnotation,\n compareResultsForExecuteWithSchema,\n drainExecution,\n graphqlExecuteOrSubscribe,\n };\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import {\n DocumentNode,\n GraphQLSchema,\n Kind,\n OperationDefinitionNode,\n parse,\n ExecutionArgs,\n ExecutionArgs as GraphQLExecutionArgs,\n ExecutionResult as GraphQLExecutionResult,\n} from \"graphql\";\nimport { executeWithSchema } from \"../executeWithSchema\";\nimport { typeDefs } from \"../benchmarks/swapi-schema\";\nimport resolvers from \"../benchmarks/swapi-schema/resolvers\";\nimport { ExecutionResult, UserResolvers } from \"../types\";\nimport models from \"../benchmarks/swapi-schema/models\";\nimport { executeWithoutSchema } from \"../executeWithoutSchema\";\nimport { extractMinimalViableSchemaForRequestDocument } from \"../utilities/extractMinimalViableSchemaForRequestDocument\";\nimport { PromiseOrValue } from \"graphql/jsutils/PromiseOrValue\";\nimport { ObjMap } from \"../jsutils/ObjMap\";\nimport { forAwaitEach, isAsyncIterable } from \"iterall\";\n\ntype GraphQLResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> =\n | GraphQLExecutionResult<TData, TExtensions>\n | AsyncGenerator<GraphQLExecutionResult<TData, TExtensions>, void, void>;\n\nexport function createExecutionUtils(\n graphqlExecute: (args: ExecutionArgs) => PromiseOrValue<ExecutionResult>,\n graphqlSubscribe: (\n args: ExecutionArgs,\n ) => PromiseOrValue<AsyncIterableIterator<ExecutionResult> | ExecutionResult>,\n) {\n async function compareResultsForExecuteWithSchema(\n schema: GraphQLSchema,\n query: string,\n variables?: Record<string, unknown>,\n enablePerEventContext?: boolean,\n ) {\n expect.assertions(1);\n const document = parse(query);\n const result = await drainExecution(\n await executeWithSchema({\n document,\n definitions: typeDefs,\n resolvers: resolvers as UserResolvers<unknown, unknown>,\n contextValue: {\n models,\n },\n variableValues: variables,\n enablePerEventContext,\n }),\n );\n const validResult = await drainExecution(\n await graphqlExecuteOrSubscribe({\n document,\n contextValue: {\n models,\n },\n schema,\n variableValues: variables,\n }),\n );\n expect(result).toEqual(validResult);\n }\n\n async function compareResultForExecuteWithoutSchemaWithMVSAnnotation(\n schema: GraphQLSchema,\n query: string,\n variables: Record<string, unknown> = {},\n enablePerEventContext?: boolean,\n ) {\n expect.assertions(1);\n const document = parse(query);\n const { definitions } = extractMinimalViableSchemaForRequestDocument(\n schema,\n document,\n );\n const result = await drainExecution(\n await executeWithoutSchema({\n document,\n contextValue: {\n models,\n },\n schemaFragment: {\n schemaId: \"test\",\n definitions,\n resolvers: resolvers as UserResolvers,\n },\n variableValues: variables,\n enablePerEventContext,\n }),\n );\n const validResult = await drainExecution(\n await graphqlExecuteOrSubscribe({\n document,\n contextValue: {\n models,\n },\n schema,\n variableValues: variables,\n }),\n );\n expect(result).toEqual(validResult);\n }\n\n function graphqlExecuteOrSubscribe(\n args: GraphQLExecutionArgs,\n ): PromiseOrValue<GraphQLResult> {\n const operationName = args.operationName;\n let operation: OperationDefinitionNode | undefined;\n for (const definition of (args.document as unknown as DocumentNode)\n .definitions) {\n switch (definition.kind) {\n case Kind.OPERATION_DEFINITION:\n if (operationName == null) {\n if (operation !== undefined) {\n throw new Error(\"Bad operation in test\");\n }\n operation = definition;\n } else if (definition.name?.value === operationName) {\n operation = definition;\n }\n break;\n }\n }\n if (!operation) {\n throw new Error(\"Bad operation in test\");\n }\n\n if (operation.operation === \"subscription\") {\n return graphqlSubscribe(args) as GraphQLResult;\n } else {\n return graphqlExecute(args) as GraphQLResult;\n }\n }\n\n async function drainExecution(\n result: ExecutionResult | GraphQLResult,\n ): Promise<unknown> {\n let processedResult;\n if (isAsyncIterable(result)) {\n processedResult = await drainAsyncGeneratorToArray(result);\n } else if (\"subsequentResults\" in result) {\n processedResult = {\n ...result,\n subsequentResults: await drainAsyncGeneratorToArray(\n result.subsequentResults,\n ),\n };\n } else {\n processedResult = result;\n }\n return processedResult;\n }\n\n async function drainAsyncGeneratorToArray<T>(\n collection: AsyncGenerator<T, void, void>,\n ): Promise<T[]> {\n const result: T[] = [];\n await forAwaitEach(collection, (item) => result.push(item));\n return result;\n }\n\n return {\n compareResultForExecuteWithoutSchemaWithMVSAnnotation,\n compareResultsForExecuteWithSchema,\n drainExecution,\n graphqlExecuteOrSubscribe,\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBASO;AACP,+BAAkC;AAClC,0B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
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __async = (__this, __arguments, generator) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
var fulfilled = (value) => {
|
|
23
|
-
try {
|
|
24
|
-
step(generator.next(value));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
reject(e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var rejected = (value) => {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.throw(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
1
|
// src/__testUtils__/execute.ts
|
|
42
2
|
import {
|
|
43
3
|
Kind,
|
|
@@ -51,68 +11,66 @@ import { executeWithoutSchema } from "../executeWithoutSchema.mjs";
|
|
|
51
11
|
import { extractMinimalViableSchemaForRequestDocument } from "../utilities/extractMinimalViableSchemaForRequestDocument.mjs";
|
|
52
12
|
import { forAwaitEach, isAsyncIterable } from "iterall";
|
|
53
13
|
function createExecutionUtils(graphqlExecute, graphqlSubscribe) {
|
|
54
|
-
function compareResultsForExecuteWithSchema(schema, query, variables) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
});
|
|
14
|
+
async function compareResultsForExecuteWithSchema(schema, query, variables, enablePerEventContext) {
|
|
15
|
+
expect.assertions(1);
|
|
16
|
+
const document = parse(query);
|
|
17
|
+
const result = await drainExecution(
|
|
18
|
+
await executeWithSchema({
|
|
19
|
+
document,
|
|
20
|
+
definitions: typeDefs,
|
|
21
|
+
resolvers,
|
|
22
|
+
contextValue: {
|
|
23
|
+
models
|
|
24
|
+
},
|
|
25
|
+
variableValues: variables,
|
|
26
|
+
enablePerEventContext
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
const validResult = await drainExecution(
|
|
30
|
+
await graphqlExecuteOrSubscribe({
|
|
31
|
+
document,
|
|
32
|
+
contextValue: {
|
|
33
|
+
models
|
|
34
|
+
},
|
|
35
|
+
schema,
|
|
36
|
+
variableValues: variables
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
expect(result).toEqual(validResult);
|
|
81
40
|
}
|
|
82
|
-
function compareResultForExecuteWithoutSchemaWithMVSAnnotation(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
41
|
+
async function compareResultForExecuteWithoutSchemaWithMVSAnnotation(schema, query, variables = {}, enablePerEventContext) {
|
|
42
|
+
expect.assertions(1);
|
|
43
|
+
const document = parse(query);
|
|
44
|
+
const { definitions } = extractMinimalViableSchemaForRequestDocument(
|
|
45
|
+
schema,
|
|
46
|
+
document
|
|
47
|
+
);
|
|
48
|
+
const result = await drainExecution(
|
|
49
|
+
await executeWithoutSchema({
|
|
50
|
+
document,
|
|
51
|
+
contextValue: {
|
|
52
|
+
models
|
|
53
|
+
},
|
|
54
|
+
schemaFragment: {
|
|
55
|
+
schemaId: "test",
|
|
56
|
+
definitions,
|
|
57
|
+
resolvers
|
|
58
|
+
},
|
|
59
|
+
variableValues: variables,
|
|
60
|
+
enablePerEventContext
|
|
61
|
+
})
|
|
62
|
+
);
|
|
63
|
+
const validResult = await drainExecution(
|
|
64
|
+
await graphqlExecuteOrSubscribe({
|
|
65
|
+
document,
|
|
66
|
+
contextValue: {
|
|
67
|
+
models
|
|
68
|
+
},
|
|
87
69
|
schema,
|
|
88
|
-
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
document,
|
|
93
|
-
contextValue: {
|
|
94
|
-
models
|
|
95
|
-
},
|
|
96
|
-
schemaFragment: {
|
|
97
|
-
schemaId: "test",
|
|
98
|
-
definitions,
|
|
99
|
-
resolvers
|
|
100
|
-
},
|
|
101
|
-
variableValues: variables
|
|
102
|
-
})
|
|
103
|
-
);
|
|
104
|
-
const validResult = yield drainExecution(
|
|
105
|
-
yield graphqlExecuteOrSubscribe({
|
|
106
|
-
document,
|
|
107
|
-
contextValue: {
|
|
108
|
-
models
|
|
109
|
-
},
|
|
110
|
-
schema,
|
|
111
|
-
variableValues: variables
|
|
112
|
-
})
|
|
113
|
-
);
|
|
114
|
-
expect(result).toEqual(validResult);
|
|
115
|
-
});
|
|
70
|
+
variableValues: variables
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
expect(result).toEqual(validResult);
|
|
116
74
|
}
|
|
117
75
|
function graphqlExecuteOrSubscribe(args) {
|
|
118
76
|
var _a;
|
|
@@ -141,29 +99,26 @@ function createExecutionUtils(graphqlExecute, graphqlSubscribe) {
|
|
|
141
99
|
return graphqlExecute(args);
|
|
142
100
|
}
|
|
143
101
|
}
|
|
144
|
-
function drainExecution(result) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
});
|
|
102
|
+
async function drainExecution(result) {
|
|
103
|
+
let processedResult;
|
|
104
|
+
if (isAsyncIterable(result)) {
|
|
105
|
+
processedResult = await drainAsyncGeneratorToArray(result);
|
|
106
|
+
} else if ("subsequentResults" in result) {
|
|
107
|
+
processedResult = {
|
|
108
|
+
...result,
|
|
109
|
+
subsequentResults: await drainAsyncGeneratorToArray(
|
|
110
|
+
result.subsequentResults
|
|
111
|
+
)
|
|
112
|
+
};
|
|
113
|
+
} else {
|
|
114
|
+
processedResult = result;
|
|
115
|
+
}
|
|
116
|
+
return processedResult;
|
|
160
117
|
}
|
|
161
|
-
function drainAsyncGeneratorToArray(collection) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return result;
|
|
166
|
-
});
|
|
118
|
+
async function drainAsyncGeneratorToArray(collection) {
|
|
119
|
+
const result = [];
|
|
120
|
+
await forAwaitEach(collection, (item) => result.push(item));
|
|
121
|
+
return result;
|
|
167
122
|
}
|
|
168
123
|
return {
|
|
169
124
|
compareResultForExecuteWithoutSchemaWithMVSAnnotation,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/__testUtils__/execute.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n DocumentNode,\n GraphQLSchema,\n Kind,\n OperationDefinitionNode,\n parse,\n ExecutionArgs,\n ExecutionArgs as GraphQLExecutionArgs,\n ExecutionResult as GraphQLExecutionResult,\n} from \"graphql\";\nimport { executeWithSchema } from \"../executeWithSchema\";\nimport { typeDefs } from \"../benchmarks/swapi-schema\";\nimport resolvers from \"../benchmarks/swapi-schema/resolvers\";\nimport { ExecutionResult, UserResolvers } from \"../types\";\nimport models from \"../benchmarks/swapi-schema/models\";\nimport { executeWithoutSchema } from \"../executeWithoutSchema\";\nimport { extractMinimalViableSchemaForRequestDocument } from \"../utilities/extractMinimalViableSchemaForRequestDocument\";\nimport { PromiseOrValue } from \"graphql/jsutils/PromiseOrValue\";\nimport { ObjMap } from \"../jsutils/ObjMap\";\nimport { forAwaitEach, isAsyncIterable } from \"iterall\";\n\ntype GraphQLResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> =\n | GraphQLExecutionResult<TData, TExtensions>\n | AsyncGenerator<GraphQLExecutionResult<TData, TExtensions>, void, void>;\n\nexport function createExecutionUtils(\n graphqlExecute: (args: ExecutionArgs) => PromiseOrValue<ExecutionResult>,\n graphqlSubscribe: (\n args: ExecutionArgs,\n ) => PromiseOrValue<AsyncIterableIterator<ExecutionResult> | ExecutionResult>,\n) {\n async function compareResultsForExecuteWithSchema(\n schema: GraphQLSchema,\n query: string,\n variables?: Record<string, unknown>,\n ) {\n expect.assertions(1);\n const document = parse(query);\n const result = await drainExecution(\n await executeWithSchema({\n document,\n definitions: typeDefs,\n resolvers: resolvers as UserResolvers<unknown, unknown>,\n contextValue: {\n models,\n },\n variableValues: variables,\n }),\n );\n const validResult = await drainExecution(\n await graphqlExecuteOrSubscribe({\n document,\n contextValue: {\n models,\n },\n schema,\n variableValues: variables,\n }),\n );\n expect(result).toEqual(validResult);\n }\n\n async function compareResultForExecuteWithoutSchemaWithMVSAnnotation(\n schema: GraphQLSchema,\n query: string,\n variables: Record<string, unknown> = {},\n ) {\n expect.assertions(1);\n const document = parse(query);\n const { definitions } = extractMinimalViableSchemaForRequestDocument(\n schema,\n document,\n );\n const result = await drainExecution(\n await executeWithoutSchema({\n document,\n contextValue: {\n models,\n },\n schemaFragment: {\n schemaId: \"test\",\n definitions,\n resolvers: resolvers as UserResolvers,\n },\n variableValues: variables,\n }),\n );\n const validResult = await drainExecution(\n await graphqlExecuteOrSubscribe({\n document,\n contextValue: {\n models,\n },\n schema,\n variableValues: variables,\n }),\n );\n expect(result).toEqual(validResult);\n }\n\n function graphqlExecuteOrSubscribe(\n args: GraphQLExecutionArgs,\n ): PromiseOrValue<GraphQLResult> {\n const operationName = args.operationName;\n let operation: OperationDefinitionNode | undefined;\n for (const definition of (args.document as unknown as DocumentNode)\n .definitions) {\n switch (definition.kind) {\n case Kind.OPERATION_DEFINITION:\n if (operationName == null) {\n if (operation !== undefined) {\n throw new Error(\"Bad operation in test\");\n }\n operation = definition;\n } else if (definition.name?.value === operationName) {\n operation = definition;\n }\n break;\n }\n }\n if (!operation) {\n throw new Error(\"Bad operation in test\");\n }\n\n if (operation.operation === \"subscription\") {\n return graphqlSubscribe(args) as GraphQLResult;\n } else {\n return graphqlExecute(args) as GraphQLResult;\n }\n }\n\n async function drainExecution(\n result: ExecutionResult | GraphQLResult,\n ): Promise<unknown> {\n let processedResult;\n if (isAsyncIterable(result)) {\n processedResult = await drainAsyncGeneratorToArray(result);\n } else if (\"subsequentResults\" in result) {\n processedResult = {\n ...result,\n subsequentResults: await drainAsyncGeneratorToArray(\n result.subsequentResults,\n ),\n };\n } else {\n processedResult = result;\n }\n return processedResult;\n }\n\n async function drainAsyncGeneratorToArray<T>(\n collection: AsyncGenerator<T, void, void>,\n ): Promise<T[]> {\n const result: T[] = [];\n await forAwaitEach(collection, (item) => result.push(item));\n return result;\n }\n\n return {\n compareResultForExecuteWithoutSchemaWithMVSAnnotation,\n compareResultsForExecuteWithSchema,\n drainExecution,\n graphqlExecuteOrSubscribe,\n };\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import {\n DocumentNode,\n GraphQLSchema,\n Kind,\n OperationDefinitionNode,\n parse,\n ExecutionArgs,\n ExecutionArgs as GraphQLExecutionArgs,\n ExecutionResult as GraphQLExecutionResult,\n} from \"graphql\";\nimport { executeWithSchema } from \"../executeWithSchema\";\nimport { typeDefs } from \"../benchmarks/swapi-schema\";\nimport resolvers from \"../benchmarks/swapi-schema/resolvers\";\nimport { ExecutionResult, UserResolvers } from \"../types\";\nimport models from \"../benchmarks/swapi-schema/models\";\nimport { executeWithoutSchema } from \"../executeWithoutSchema\";\nimport { extractMinimalViableSchemaForRequestDocument } from \"../utilities/extractMinimalViableSchemaForRequestDocument\";\nimport { PromiseOrValue } from \"graphql/jsutils/PromiseOrValue\";\nimport { ObjMap } from \"../jsutils/ObjMap\";\nimport { forAwaitEach, isAsyncIterable } from \"iterall\";\n\ntype GraphQLResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> =\n | GraphQLExecutionResult<TData, TExtensions>\n | AsyncGenerator<GraphQLExecutionResult<TData, TExtensions>, void, void>;\n\nexport function createExecutionUtils(\n graphqlExecute: (args: ExecutionArgs) => PromiseOrValue<ExecutionResult>,\n graphqlSubscribe: (\n args: ExecutionArgs,\n ) => PromiseOrValue<AsyncIterableIterator<ExecutionResult> | ExecutionResult>,\n) {\n async function compareResultsForExecuteWithSchema(\n schema: GraphQLSchema,\n query: string,\n variables?: Record<string, unknown>,\n enablePerEventContext?: boolean,\n ) {\n expect.assertions(1);\n const document = parse(query);\n const result = await drainExecution(\n await executeWithSchema({\n document,\n definitions: typeDefs,\n resolvers: resolvers as UserResolvers<unknown, unknown>,\n contextValue: {\n models,\n },\n variableValues: variables,\n enablePerEventContext,\n }),\n );\n const validResult = await drainExecution(\n await graphqlExecuteOrSubscribe({\n document,\n contextValue: {\n models,\n },\n schema,\n variableValues: variables,\n }),\n );\n expect(result).toEqual(validResult);\n }\n\n async function compareResultForExecuteWithoutSchemaWithMVSAnnotation(\n schema: GraphQLSchema,\n query: string,\n variables: Record<string, unknown> = {},\n enablePerEventContext?: boolean,\n ) {\n expect.assertions(1);\n const document = parse(query);\n const { definitions } = extractMinimalViableSchemaForRequestDocument(\n schema,\n document,\n );\n const result = await drainExecution(\n await executeWithoutSchema({\n document,\n contextValue: {\n models,\n },\n schemaFragment: {\n schemaId: \"test\",\n definitions,\n resolvers: resolvers as UserResolvers,\n },\n variableValues: variables,\n enablePerEventContext,\n }),\n );\n const validResult = await drainExecution(\n await graphqlExecuteOrSubscribe({\n document,\n contextValue: {\n models,\n },\n schema,\n variableValues: variables,\n }),\n );\n expect(result).toEqual(validResult);\n }\n\n function graphqlExecuteOrSubscribe(\n args: GraphQLExecutionArgs,\n ): PromiseOrValue<GraphQLResult> {\n const operationName = args.operationName;\n let operation: OperationDefinitionNode | undefined;\n for (const definition of (args.document as unknown as DocumentNode)\n .definitions) {\n switch (definition.kind) {\n case Kind.OPERATION_DEFINITION:\n if (operationName == null) {\n if (operation !== undefined) {\n throw new Error(\"Bad operation in test\");\n }\n operation = definition;\n } else if (definition.name?.value === operationName) {\n operation = definition;\n }\n break;\n }\n }\n if (!operation) {\n throw new Error(\"Bad operation in test\");\n }\n\n if (operation.operation === \"subscription\") {\n return graphqlSubscribe(args) as GraphQLResult;\n } else {\n return graphqlExecute(args) as GraphQLResult;\n }\n }\n\n async function drainExecution(\n result: ExecutionResult | GraphQLResult,\n ): Promise<unknown> {\n let processedResult;\n if (isAsyncIterable(result)) {\n processedResult = await drainAsyncGeneratorToArray(result);\n } else if (\"subsequentResults\" in result) {\n processedResult = {\n ...result,\n subsequentResults: await drainAsyncGeneratorToArray(\n result.subsequentResults,\n ),\n };\n } else {\n processedResult = result;\n }\n return processedResult;\n }\n\n async function drainAsyncGeneratorToArray<T>(\n collection: AsyncGenerator<T, void, void>,\n ): Promise<T[]> {\n const result: T[] = [];\n await forAwaitEach(collection, (item) => result.push(item));\n return result;\n }\n\n return {\n compareResultForExecuteWithoutSchemaWithMVSAnnotation,\n compareResultsForExecute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