@graphitation/supermassive 3.9.0 → 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 +10 -2
- package/lib/__testUtils__/execute.js +77 -121
- package/lib/__testUtils__/execute.js.map +1 -1
- package/lib/__testUtils__/execute.mjs +77 -124
- package/lib/__testUtils__/execute.mjs.map +1 -1
- 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/executeWithoutSchema.js +199 -248
- package/lib/executeWithoutSchema.js.map +1 -1
- package/lib/executeWithoutSchema.mjs +199 -251
- package/lib/executeWithoutSchema.mjs.map +1 -1
- 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/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,12 +1,20 @@
|
|
|
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
|
+
|
|
7
15
|
## 3.9.0
|
|
8
16
|
|
|
9
|
-
Fri, 28 Mar 2025 09:
|
|
17
|
+
Fri, 28 Mar 2025 09:57:05 GMT
|
|
10
18
|
|
|
11
19
|
### Minor changes
|
|
12
20
|
|
|
@@ -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,70 +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, enablePerEventContext) {
|
|
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
|
-
expect(result).toEqual(validResult);
|
|
107
|
-
});
|
|
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);
|
|
108
69
|
}
|
|
109
|
-
function compareResultForExecuteWithoutSchemaWithMVSAnnotation(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
+
},
|
|
114
98
|
schema,
|
|
115
|
-
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
document,
|
|
120
|
-
contextValue: {
|
|
121
|
-
models: import_models.default
|
|
122
|
-
},
|
|
123
|
-
schemaFragment: {
|
|
124
|
-
schemaId: "test",
|
|
125
|
-
definitions,
|
|
126
|
-
resolvers: import_resolvers.default
|
|
127
|
-
},
|
|
128
|
-
variableValues: variables,
|
|
129
|
-
enablePerEventContext
|
|
130
|
-
})
|
|
131
|
-
);
|
|
132
|
-
const validResult = yield drainExecution(
|
|
133
|
-
yield graphqlExecuteOrSubscribe({
|
|
134
|
-
document,
|
|
135
|
-
contextValue: {
|
|
136
|
-
models: import_models.default
|
|
137
|
-
},
|
|
138
|
-
schema,
|
|
139
|
-
variableValues: variables
|
|
140
|
-
})
|
|
141
|
-
);
|
|
142
|
-
expect(result).toEqual(validResult);
|
|
143
|
-
});
|
|
99
|
+
variableValues: variables
|
|
100
|
+
})
|
|
101
|
+
);
|
|
102
|
+
expect(result).toEqual(validResult);
|
|
144
103
|
}
|
|
145
104
|
function graphqlExecuteOrSubscribe(args) {
|
|
146
105
|
var _a;
|
|
@@ -169,29 +128,26 @@ function createExecutionUtils(graphqlExecute, graphqlSubscribe) {
|
|
|
169
128
|
return graphqlExecute(args);
|
|
170
129
|
}
|
|
171
130
|
}
|
|
172
|
-
function drainExecution(result) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
});
|
|
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;
|
|
188
146
|
}
|
|
189
|
-
function drainAsyncGeneratorToArray(collection) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return result;
|
|
194
|
-
});
|
|
147
|
+
async function drainAsyncGeneratorToArray(collection) {
|
|
148
|
+
const result = [];
|
|
149
|
+
await (0, import_iterall.forAwaitEach)(collection, (item) => result.push(item));
|
|
150
|
+
return result;
|
|
195
151
|
}
|
|
196
152
|
return {
|
|
197
153
|
compareResultForExecuteWithoutSchemaWithMVSAnnotation,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/__testUtils__/execute.ts"],
|
|
4
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": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBASO;AACP,+BAAkC;AAClC,0BAAyB;AACzB,uBAAsB;AAEtB,oBAAmB;AACnB,kCAAqC;AACrC,0DAA6D;AAG7D,qBAA8C;AAMvC,SAAS,qBACd,gBACA,kBAGA;AACA,iBAAe,mCACb,QACA,OACA,WACA,uBACA;AACA,WAAO,WAAW,CAAC;AACnB,UAAM,eAAW,sBAAM,KAAK;AAC5B,UAAM,SAAS,MAAM;AAAA,MACnB,UAAM,4CAAkB;AAAA,QACtB;AAAA,QACA,aAAa;AAAA,QACb,WAAW,iBAAAA;AAAA,QACX,cAAc;AAAA,UACZ,sBAAAC;AAAA,QACF;AAAA,QACA,gBAAgB;AAAA,QAChB;AAAA,MACF,CAAC;AAAA,IACH;AACA,UAAM,cAAc,MAAM;AAAA,MACxB,MAAM,0BAA0B;AAAA,QAC9B;AAAA,QACA,cAAc;AAAA,UACZ,sBAAAA;AAAA,QACF;AAAA,QACA;AAAA,QACA,gBAAgB;AAAA,MAClB,CAAC;AAAA,IACH;AACA,WAAO,MAAM,EAAE,QAAQ,WAAW;AAAA,EACpC;AAEA,iBAAe,sDACb,QACA,OACA,YAAqC,CAAC,GACtC,uBACA;AACA,WAAO,WAAW,CAAC;AACnB,UAAM,eAAW,sBAAM,KAAK;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QAAQ;AACxC,wBAAkB;AAAA,QAChB,GAAG;AAAA,QACH,mBAAmB,MAAM;AAAA,UACvB,OAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF,OAAO;AACL,wBAAkB;AAAA,IACpB;AACA,WAAO;AAAA,EACT;AAEA,iBAAe,2BACb,YACc;AACd,UAAM,SAAc,CAAC;AACrB,cAAM,6BAAa,YAAY,CAAC,SAAS,OAAO,KAAK,IAAI,CAAC;AAC1D,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["resolvers", "models"]
|
|
7
7
|
}
|
|
@@ -1,43 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
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,70 +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, enablePerEventContext) {
|
|
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
|
-
expect(result).toEqual(validResult);
|
|
81
|
-
});
|
|
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);
|
|
82
40
|
}
|
|
83
|
-
function compareResultForExecuteWithoutSchemaWithMVSAnnotation(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
+
},
|
|
88
69
|
schema,
|
|
89
|
-
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
document,
|
|
94
|
-
contextValue: {
|
|
95
|
-
models
|
|
96
|
-
},
|
|
97
|
-
schemaFragment: {
|
|
98
|
-
schemaId: "test",
|
|
99
|
-
definitions,
|
|
100
|
-
resolvers
|
|
101
|
-
},
|
|
102
|
-
variableValues: variables,
|
|
103
|
-
enablePerEventContext
|
|
104
|
-
})
|
|
105
|
-
);
|
|
106
|
-
const validResult = yield drainExecution(
|
|
107
|
-
yield graphqlExecuteOrSubscribe({
|
|
108
|
-
document,
|
|
109
|
-
contextValue: {
|
|
110
|
-
models
|
|
111
|
-
},
|
|
112
|
-
schema,
|
|
113
|
-
variableValues: variables
|
|
114
|
-
})
|
|
115
|
-
);
|
|
116
|
-
expect(result).toEqual(validResult);
|
|
117
|
-
});
|
|
70
|
+
variableValues: variables
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
expect(result).toEqual(validResult);
|
|
118
74
|
}
|
|
119
75
|
function graphqlExecuteOrSubscribe(args) {
|
|
120
76
|
var _a;
|
|
@@ -143,29 +99,26 @@ function createExecutionUtils(graphqlExecute, graphqlSubscribe) {
|
|
|
143
99
|
return graphqlExecute(args);
|
|
144
100
|
}
|
|
145
101
|
}
|
|
146
|
-
function drainExecution(result) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
});
|
|
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;
|
|
162
117
|
}
|
|
163
|
-
function drainAsyncGeneratorToArray(collection) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return result;
|
|
168
|
-
});
|
|
118
|
+
async function drainAsyncGeneratorToArray(collection) {
|
|
119
|
+
const result = [];
|
|
120
|
+
await forAwaitEach(collection, (item) => result.push(item));
|
|
121
|
+
return result;
|
|
169
122
|
}
|
|
170
123
|
return {
|
|
171
124
|
compareResultForExecuteWithoutSchemaWithMVSAnnotation,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/__testUtils__/execute.ts"],
|
|
4
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": "
|
|
5
|
+
"mappings": ";AAAA;AAAA,EAGE;AAAA,EAEA;AAAA,OAIK;AACP,SAAS,yBAAyB;AAClC,SAAS,gBAAgB;AACzB,OAAO,eAAe;AAEtB,OAAO,YAAY;AACnB,SAAS,4BAA4B;AACrC,SAAS,oDAAoD;AAG7D,SAAS,cAAc,uBAAuB;AAMvC,SAAS,qBACd,gBACA,kBAGA;AACA,iBAAe,mCACb,QACA,OACA,WACA,uBACA;AACA,WAAO,WAAW,CAAC;AACnB,UAAM,WAAW,MAAM,KAAK;AAC5B,UAAM,SAAS,MAAM;AAAA,MACnB,MAAM,kBAAkB;AAAA,QACtB;AAAA,QACA,aAAa;AAAA,QACb;AAAA,QACA,cAAc;AAAA,UACZ;AAAA,QACF;AAAA,QACA,gBAAgB;AAAA,QAChB;AAAA,MACF,CAAC;AAAA,IACH;AACA,UAAM,cAAc,MAAM;AAAA,MACxB,MAAM,0BAA0B;AAAA,QAC9B;AAAA,QACA,cAAc;AAAA,UACZ;AAAA,QACF;AAAA,QACA;AAAA,QACA,gBAAg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