@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
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
# Change Log - @graphitation/supermassive
|
|
2
2
|
|
|
3
|
-
This log was last generated on Tue,
|
|
3
|
+
This log was last generated on Tue, 29 Aug 2023 15:06:31 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 3.0.0-alpha.3
|
|
8
|
+
|
|
9
|
+
Tue, 29 Aug 2023 15:06:31 GMT
|
|
10
|
+
|
|
11
|
+
### Changes
|
|
12
|
+
|
|
13
|
+
- New type annotation strategy (vladimir.razuvaev@gmail.com)
|
|
14
|
+
|
|
15
|
+
## 3.0.0-alpha.1
|
|
16
|
+
|
|
17
|
+
Tue, 27 Jun 2023 11:47:30 GMT
|
|
18
|
+
|
|
19
|
+
### Changes
|
|
20
|
+
|
|
21
|
+
- Supermassive v3 alpha - defer and stream stuff (mnovikov@microsoft.com)
|
|
22
|
+
|
|
7
23
|
## 2.6.0
|
|
8
24
|
|
|
9
25
|
Tue, 20 Jun 2023 11:38:47 GMT
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GraphQLSchema, ExecutionArgs, ExecutionArgs as GraphQLExecutionArgs, ExecutionResult as GraphQLExecutionResult } from "graphql";
|
|
2
|
+
import { ExecutionResult } from "../types";
|
|
3
|
+
import { PromiseOrValue } from "graphql/jsutils/PromiseOrValue";
|
|
4
|
+
import { ObjMap } from "../jsutils/ObjMap";
|
|
5
|
+
type GraphQLResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> = GraphQLExecutionResult<TData, TExtensions> | AsyncGenerator<GraphQLExecutionResult<TData, TExtensions>, void, void>;
|
|
6
|
+
export declare function createExecutionUtils(graphqlExecute: (args: ExecutionArgs) => PromiseOrValue<ExecutionResult>, graphqlSubscribe: (args: ExecutionArgs) => PromiseOrValue<AsyncGenerator<ExecutionResult, void, void> | ExecutionResult>): {
|
|
7
|
+
compareResultForExecuteWithoutSchemaWithMVSAnnotation: (schema: GraphQLSchema, query: string, variables?: Record<string, unknown>) => Promise<void>;
|
|
8
|
+
compareResultsForExecuteWithSchema: (schema: GraphQLSchema, query: string, variables?: Record<string, unknown>) => Promise<void>;
|
|
9
|
+
drainExecution: (result: ExecutionResult | GraphQLResult) => Promise<unknown>;
|
|
10
|
+
graphqlExecuteOrSubscribe: (args: GraphQLExecutionArgs) => PromiseOrValue<GraphQLResult>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=execute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/__testUtils__/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EAKb,aAAa,EACb,aAAa,IAAI,oBAAoB,EACrC,eAAe,IAAI,sBAAsB,EAC1C,MAAM,SAAS,CAAC;AAIjB,OAAO,EAAE,eAAe,EAAiB,MAAM,UAAU,CAAC;AAK1D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,KAAK,aAAa,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,IACrE,sBAAsB,CAAC,KAAK,EAAE,WAAW,CAAC,GAC1C,cAAc,CAAC,sBAAsB,CAAC,KAAK,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAE3E,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,cAAc,CAAC,eAAe,CAAC,EACxE,gBAAgB,EAAE,CAChB,IAAI,EAAE,aAAa,KAChB,cAAc,CACjB,cAAc,CAAC,eAAe,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,eAAe,CAC9D;oEAkCS,aAAa,SACd,MAAM,cACF,OAAO,MAAM,EAAE,OAAO,CAAC;iDAjC1B,aAAa,SACd,MAAM,cACD,OAAO,MAAM,EAAE,OAAO,CAAC;6BA8F3B,eAAe,GAAG,aAAa,KACtC,QAAQ,OAAO,CAAC;sCAhCX,oBAAoB,KACzB,eAAe,aAAa,CAAC;EA8DjC"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
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
|
+
var __export = (target, all) => {
|
|
26
|
+
for (var name in all)
|
|
27
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
|
+
};
|
|
29
|
+
var __copyProps = (to, from, except, desc) => {
|
|
30
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
31
|
+
for (let key of __getOwnPropNames(from))
|
|
32
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
33
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
34
|
+
}
|
|
35
|
+
return to;
|
|
36
|
+
};
|
|
37
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
38
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
39
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
40
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
41
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
42
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
43
|
+
mod
|
|
44
|
+
));
|
|
45
|
+
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
|
+
var execute_exports = {};
|
|
67
|
+
__export(execute_exports, {
|
|
68
|
+
createExecutionUtils: () => createExecutionUtils
|
|
69
|
+
});
|
|
70
|
+
module.exports = __toCommonJS(execute_exports);
|
|
71
|
+
var import_graphql = require("graphql");
|
|
72
|
+
var import_executeWithSchema = require("../executeWithSchema");
|
|
73
|
+
var import_swapi_schema = require("../benchmarks/swapi-schema");
|
|
74
|
+
var import_resolvers = __toESM(require("../benchmarks/swapi-schema/resolvers"));
|
|
75
|
+
var import_models = __toESM(require("../benchmarks/swapi-schema/models"));
|
|
76
|
+
var import_executeWithoutSchema = require("../executeWithoutSchema");
|
|
77
|
+
var import_addMinimalViableSchemaToRequestDocument = require("../utilities/addMinimalViableSchemaToRequestDocument");
|
|
78
|
+
var import_iterall = require("iterall");
|
|
79
|
+
function createExecutionUtils(graphqlExecute, graphqlSubscribe) {
|
|
80
|
+
function compareResultsForExecuteWithSchema(schema, query, variables) {
|
|
81
|
+
return __async(this, null, function* () {
|
|
82
|
+
expect.assertions(1);
|
|
83
|
+
const document = (0, import_graphql.parse)(query);
|
|
84
|
+
const result = yield drainExecution(
|
|
85
|
+
yield (0, import_executeWithSchema.executeWithSchema)({
|
|
86
|
+
typeDefs: import_swapi_schema.typeDefs,
|
|
87
|
+
resolvers: import_resolvers.default,
|
|
88
|
+
document,
|
|
89
|
+
contextValue: {
|
|
90
|
+
models: import_models.default
|
|
91
|
+
},
|
|
92
|
+
variableValues: variables
|
|
93
|
+
})
|
|
94
|
+
);
|
|
95
|
+
const validResult = yield drainExecution(
|
|
96
|
+
yield graphqlExecuteOrSubscribe({
|
|
97
|
+
document,
|
|
98
|
+
contextValue: {
|
|
99
|
+
models: import_models.default
|
|
100
|
+
},
|
|
101
|
+
schema,
|
|
102
|
+
variableValues: variables
|
|
103
|
+
})
|
|
104
|
+
);
|
|
105
|
+
expect(result).toEqual(validResult);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function compareResultForExecuteWithoutSchemaWithMVSAnnotation(_0, _1) {
|
|
109
|
+
return __async(this, arguments, function* (schema, query, variables = {}) {
|
|
110
|
+
expect.assertions(1);
|
|
111
|
+
const document = (0, import_graphql.parse)(query);
|
|
112
|
+
const result = yield drainExecution(
|
|
113
|
+
yield (0, import_executeWithoutSchema.executeWithoutSchema)({
|
|
114
|
+
document,
|
|
115
|
+
contextValue: {
|
|
116
|
+
models: import_models.default
|
|
117
|
+
},
|
|
118
|
+
resolvers: import_resolvers.default,
|
|
119
|
+
schemaFragment: (0, import_addMinimalViableSchemaToRequestDocument.extractMinimalViableSchemaForRequestDocument)(
|
|
120
|
+
schema,
|
|
121
|
+
document
|
|
122
|
+
),
|
|
123
|
+
variableValues: variables
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
const validResult = yield drainExecution(
|
|
127
|
+
yield graphqlExecuteOrSubscribe({
|
|
128
|
+
document,
|
|
129
|
+
contextValue: {
|
|
130
|
+
models: import_models.default
|
|
131
|
+
},
|
|
132
|
+
schema,
|
|
133
|
+
variableValues: variables
|
|
134
|
+
})
|
|
135
|
+
);
|
|
136
|
+
expect(result).toEqual(validResult);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function graphqlExecuteOrSubscribe(args) {
|
|
140
|
+
var _a;
|
|
141
|
+
const operationName = args.operationName;
|
|
142
|
+
let operation;
|
|
143
|
+
for (const definition of args.document.definitions) {
|
|
144
|
+
switch (definition.kind) {
|
|
145
|
+
case import_graphql.Kind.OPERATION_DEFINITION:
|
|
146
|
+
if (operationName == null) {
|
|
147
|
+
if (operation !== void 0) {
|
|
148
|
+
throw new Error("Bad operation in test");
|
|
149
|
+
}
|
|
150
|
+
operation = definition;
|
|
151
|
+
} else if (((_a = definition.name) == null ? void 0 : _a.value) === operationName) {
|
|
152
|
+
operation = definition;
|
|
153
|
+
}
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (!operation) {
|
|
158
|
+
throw new Error("Bad operation in test");
|
|
159
|
+
}
|
|
160
|
+
if (operation.operation === import_graphql.OperationTypeNode.SUBSCRIPTION) {
|
|
161
|
+
return graphqlSubscribe(args);
|
|
162
|
+
} else {
|
|
163
|
+
return graphqlExecute(args);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function drainExecution(result) {
|
|
167
|
+
return __async(this, null, function* () {
|
|
168
|
+
let processedResult;
|
|
169
|
+
if ((0, import_iterall.isAsyncIterable)(result)) {
|
|
170
|
+
processedResult = yield drainAsyncGeneratorToArray(result);
|
|
171
|
+
} else if ("subsequentResults" in result) {
|
|
172
|
+
processedResult = __spreadProps(__spreadValues({}, result), {
|
|
173
|
+
subsequentResults: yield drainAsyncGeneratorToArray(
|
|
174
|
+
result.subsequentResults
|
|
175
|
+
)
|
|
176
|
+
});
|
|
177
|
+
} else {
|
|
178
|
+
processedResult = result;
|
|
179
|
+
}
|
|
180
|
+
return processedResult;
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
function drainAsyncGeneratorToArray(collection) {
|
|
184
|
+
return __async(this, null, function* () {
|
|
185
|
+
const result = [];
|
|
186
|
+
yield (0, import_iterall.forAwaitEach)(collection, (item) => result.push(item));
|
|
187
|
+
return result;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
compareResultForExecuteWithoutSchemaWithMVSAnnotation,
|
|
192
|
+
compareResultsForExecuteWithSchema,
|
|
193
|
+
drainExecution,
|
|
194
|
+
graphqlExecuteOrSubscribe
|
|
195
|
+
};
|
|
196
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/__testUtils__/execute.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n DocumentNode,\n GraphQLSchema,\n Kind,\n OperationDefinitionNode,\n OperationTypeNode,\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/addMinimalViableSchemaToRequestDocument\";\nimport {} from \"graphql/execution/execute\";\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<\n AsyncGenerator<ExecutionResult, void, void> | ExecutionResult\n >,\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 typeDefs,\n resolvers: resolvers as UserResolvers<unknown, unknown>,\n document,\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 result = await drainExecution(\n await executeWithoutSchema({\n document,\n contextValue: {\n models,\n },\n resolvers: resolvers as UserResolvers,\n schemaFragment: extractMinimalViableSchemaForRequestDocument(\n schema,\n document,\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 === OperationTypeNode.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,qBAUO;AACP,+BAAkC;AAClC,0BAAyB;AACzB,uBAAsB;AAEtB,oBAAmB;AACnB,kCAAqC;AACrC,qDAA6D;AAI7D,qBAA8C;AAMvC,SAAS,qBACd,gBACA,kBAKA;AACA,WAAe,mCACb,QACA,OACA,WACA;AAAA;AACA,aAAO,WAAW,CAAC;AACnB,YAAM,eAAW,sBAAM,KAAK;AAC5B,YAAM,SAAS,MAAM;AAAA,QACnB,UAAM,4CAAkB;AAAA,UACtB;AAAA,UACA,WAAW,iBAAAA;AAAA,UACX;AAAA,UACA,cAAc;AAAA,YACZ,sBAAAC;AAAA,UACF;AAAA,UACA,gBAAgB;AAAA,QAClB,CAAC;AAAA,MACH;AACA,YAAM,cAAc,MAAM;AAAA,QACxB,MAAM,0BAA0B;AAAA,UAC9B;AAAA,UACA,cAAc;AAAA,YACZ,sBAAAA;AAAA,UACF;AAAA,UACA;AAAA,UACA,gBAAgB;AAAA,QAClB,CAAC;AAAA,MACH;AACA,aAAO,MAAM,EAAE,QAAQ,WAAW;AAAA,IACpC;AAAA;AAEA,WAAe,sDACb,IACA,IAEA;AAAA,+CAHA,QACA,OACA,YAAqC,CAAC,GACtC;AACA,aAAO,WAAW,CAAC;AACnB,YAAM,eAAW,sBAAM,KAAK;AAC5B,YAAM,SAAS,MAAM;AAAA,QACnB,UAAM,kDAAqB;AAAA,UACzB;AAAA,UACA,cAAc;AAAA,YACZ,sBAAAA;AAAA,UACF;A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WAAe,2BACb,YACc;AAAA;AACd,YAAM,SAAc,CAAC;AACrB,gBAAM,6BAAa,YAAY,CAAC,SAAS,OAAO,KAAK,IAAI,CAAC;AAC1D,aAAO;AAAA,IACT;AAAA;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["resolvers", "models"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
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
|
+
// src/__testUtils__/execute.ts
|
|
42
|
+
import {
|
|
43
|
+
Kind,
|
|
44
|
+
OperationTypeNode,
|
|
45
|
+
parse
|
|
46
|
+
} from "graphql";
|
|
47
|
+
import { executeWithSchema } from "../executeWithSchema.mjs";
|
|
48
|
+
import { typeDefs } from "../benchmarks/swapi-schema/index.mjs";
|
|
49
|
+
import resolvers from "../benchmarks/swapi-schema/resolvers.mjs";
|
|
50
|
+
import models from "../benchmarks/swapi-schema/models.mjs";
|
|
51
|
+
import { executeWithoutSchema } from "../executeWithoutSchema.mjs";
|
|
52
|
+
import { extractMinimalViableSchemaForRequestDocument } from "../utilities/addMinimalViableSchemaToRequestDocument.mjs";
|
|
53
|
+
import { forAwaitEach, isAsyncIterable } from "iterall";
|
|
54
|
+
function createExecutionUtils(graphqlExecute, graphqlSubscribe) {
|
|
55
|
+
function compareResultsForExecuteWithSchema(schema, query, variables) {
|
|
56
|
+
return __async(this, null, function* () {
|
|
57
|
+
expect.assertions(1);
|
|
58
|
+
const document = parse(query);
|
|
59
|
+
const result = yield drainExecution(
|
|
60
|
+
yield executeWithSchema({
|
|
61
|
+
typeDefs,
|
|
62
|
+
resolvers,
|
|
63
|
+
document,
|
|
64
|
+
contextValue: {
|
|
65
|
+
models
|
|
66
|
+
},
|
|
67
|
+
variableValues: variables
|
|
68
|
+
})
|
|
69
|
+
);
|
|
70
|
+
const validResult = yield drainExecution(
|
|
71
|
+
yield graphqlExecuteOrSubscribe({
|
|
72
|
+
document,
|
|
73
|
+
contextValue: {
|
|
74
|
+
models
|
|
75
|
+
},
|
|
76
|
+
schema,
|
|
77
|
+
variableValues: variables
|
|
78
|
+
})
|
|
79
|
+
);
|
|
80
|
+
expect(result).toEqual(validResult);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function compareResultForExecuteWithoutSchemaWithMVSAnnotation(_0, _1) {
|
|
84
|
+
return __async(this, arguments, function* (schema, query, variables = {}) {
|
|
85
|
+
expect.assertions(1);
|
|
86
|
+
const document = parse(query);
|
|
87
|
+
const result = yield drainExecution(
|
|
88
|
+
yield executeWithoutSchema({
|
|
89
|
+
document,
|
|
90
|
+
contextValue: {
|
|
91
|
+
models
|
|
92
|
+
},
|
|
93
|
+
resolvers,
|
|
94
|
+
schemaFragment: extractMinimalViableSchemaForRequestDocument(
|
|
95
|
+
schema,
|
|
96
|
+
document
|
|
97
|
+
),
|
|
98
|
+
variableValues: variables
|
|
99
|
+
})
|
|
100
|
+
);
|
|
101
|
+
const validResult = yield drainExecution(
|
|
102
|
+
yield graphqlExecuteOrSubscribe({
|
|
103
|
+
document,
|
|
104
|
+
contextValue: {
|
|
105
|
+
models
|
|
106
|
+
},
|
|
107
|
+
schema,
|
|
108
|
+
variableValues: variables
|
|
109
|
+
})
|
|
110
|
+
);
|
|
111
|
+
expect(result).toEqual(validResult);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function graphqlExecuteOrSubscribe(args) {
|
|
115
|
+
var _a;
|
|
116
|
+
const operationName = args.operationName;
|
|
117
|
+
let operation;
|
|
118
|
+
for (const definition of args.document.definitions) {
|
|
119
|
+
switch (definition.kind) {
|
|
120
|
+
case Kind.OPERATION_DEFINITION:
|
|
121
|
+
if (operationName == null) {
|
|
122
|
+
if (operation !== void 0) {
|
|
123
|
+
throw new Error("Bad operation in test");
|
|
124
|
+
}
|
|
125
|
+
operation = definition;
|
|
126
|
+
} else if (((_a = definition.name) == null ? void 0 : _a.value) === operationName) {
|
|
127
|
+
operation = definition;
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (!operation) {
|
|
133
|
+
throw new Error("Bad operation in test");
|
|
134
|
+
}
|
|
135
|
+
if (operation.operation === OperationTypeNode.SUBSCRIPTION) {
|
|
136
|
+
return graphqlSubscribe(args);
|
|
137
|
+
} else {
|
|
138
|
+
return graphqlExecute(args);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function drainExecution(result) {
|
|
142
|
+
return __async(this, null, function* () {
|
|
143
|
+
let processedResult;
|
|
144
|
+
if (isAsyncIterable(result)) {
|
|
145
|
+
processedResult = yield drainAsyncGeneratorToArray(result);
|
|
146
|
+
} else if ("subsequentResults" in result) {
|
|
147
|
+
processedResult = __spreadProps(__spreadValues({}, result), {
|
|
148
|
+
subsequentResults: yield drainAsyncGeneratorToArray(
|
|
149
|
+
result.subsequentResults
|
|
150
|
+
)
|
|
151
|
+
});
|
|
152
|
+
} else {
|
|
153
|
+
processedResult = result;
|
|
154
|
+
}
|
|
155
|
+
return processedResult;
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function drainAsyncGeneratorToArray(collection) {
|
|
159
|
+
return __async(this, null, function* () {
|
|
160
|
+
const result = [];
|
|
161
|
+
yield forAwaitEach(collection, (item) => result.push(item));
|
|
162
|
+
return result;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
compareResultForExecuteWithoutSchemaWithMVSAnnotation,
|
|
167
|
+
compareResultsForExecuteWithSchema,
|
|
168
|
+
drainExecution,
|
|
169
|
+
graphqlExecuteOrSubscribe
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
export {
|
|
173
|
+
createExecutionUtils
|
|
174
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/__testUtils__/execute.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n DocumentNode,\n GraphQLSchema,\n Kind,\n OperationDefinitionNode,\n OperationTypeNode,\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/addMinimalViableSchemaToRequestDocument\";\nimport {} from \"graphql/execution/execute\";\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<\n AsyncGenerator<ExecutionResult, void, void> | ExecutionResult\n >,\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 typeDefs,\n resolvers: resolvers as UserResolvers<unknown, unknown>,\n document,\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 result = await drainExecution(\n await executeWithoutSchema({\n document,\n contextValue: {\n models,\n },\n resolvers: resolvers as UserResolvers,\n schemaFragment: extractMinimalViableSchemaForRequestDocument(\n schema,\n document,\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 === OperationTypeNode.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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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("./swapi-schema/models"));
|
|
|
50
50
|
var import_graphql = require("graphql");
|
|
51
51
|
var import_graphql_jit = require("graphql-jit");
|
|
52
52
|
var import_executeWithoutSchema = require("../executeWithoutSchema");
|
|
53
|
-
var
|
|
54
|
-
var import_extractImplicitTypesRuntime = require("../extractImplicitTypesRuntime");
|
|
55
|
-
var import_values = require("../values");
|
|
53
|
+
var import_addMinimalViableSchemaToRequestDocument = require("../utilities/addMinimalViableSchemaToRequestDocument");
|
|
56
54
|
const query = import_fs.default.readFileSync(
|
|
57
55
|
import_path.default.join(__dirname, "./fixtures/query1.graphql"),
|
|
58
56
|
{
|
|
@@ -61,12 +59,15 @@ const query = import_fs.default.readFileSync(
|
|
|
61
59
|
);
|
|
62
60
|
const parsedQuery = (0, import_graphql.parse)(query);
|
|
63
61
|
const compiledQuery = (0, import_graphql_jit.compileQuery)(import_swapi_schema.default, parsedQuery);
|
|
64
|
-
const
|
|
62
|
+
const schemaFragment = (0, import_addMinimalViableSchemaToRequestDocument.extractMinimalViableSchemaForRequestDocument)(
|
|
63
|
+
import_swapi_schema.default,
|
|
64
|
+
parsedQuery
|
|
65
|
+
);
|
|
65
66
|
const queryRunningSuite = new import_nice_benchmark.default("Query Running");
|
|
66
67
|
queryRunningSuite.add("graphql-js - string queries", () => __async(exports, null, function* () {
|
|
67
|
-
const result = yield (0, import_graphql.
|
|
68
|
+
const result = yield (0, import_graphql.execute)({
|
|
68
69
|
schema: import_swapi_schema.default,
|
|
69
|
-
|
|
70
|
+
document: (0, import_graphql.parse)(query),
|
|
70
71
|
contextValue: { models: import_models.default }
|
|
71
72
|
});
|
|
72
73
|
if (result.errors || !result.data) {
|
|
@@ -105,23 +106,13 @@ queryRunningSuite.add("graphql-jit - precompiled", () => __async(exports, null,
|
|
|
105
106
|
}
|
|
106
107
|
}));
|
|
107
108
|
queryRunningSuite.add("supermassive - runtime schemaless", () => __async(exports, null, function* () {
|
|
108
|
-
let extractedResolvers = {};
|
|
109
|
-
const getTypeByName = (name) => {
|
|
110
|
-
const type = import_values.specifiedScalars[name] || extractedResolvers[name];
|
|
111
|
-
if ((0, import_graphql.isInputType)(type)) {
|
|
112
|
-
return type;
|
|
113
|
-
} else {
|
|
114
|
-
throw new Error("Invalid type");
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
extractedResolvers = (0, import_extractImplicitTypesRuntime.extractImplicitTypes)(parsedQuery, getTypeByName);
|
|
118
109
|
const result = yield (0, import_executeWithoutSchema.executeWithoutSchema)({
|
|
119
110
|
resolvers: import_resolvers.default,
|
|
120
|
-
|
|
121
|
-
document:
|
|
111
|
+
schemaFragment,
|
|
112
|
+
document: parsedQuery,
|
|
122
113
|
contextValue: { models: import_models.default }
|
|
123
114
|
});
|
|
124
|
-
if (result.errors || !result.data) {
|
|
115
|
+
if ("data" in result && (result.errors || !result.data)) {
|
|
125
116
|
throw new Error("Stuff ain't executing");
|
|
126
117
|
}
|
|
127
118
|
}));
|
|
@@ -135,7 +126,7 @@ queryCompilingSuite.add("graphql-jit", () => __async(exports, null, function* ()
|
|
|
135
126
|
}));
|
|
136
127
|
const queryAnnotationSuite = new import_nice_benchmark.default("Query annotation");
|
|
137
128
|
queryAnnotationSuite.add("supermassive", () => {
|
|
138
|
-
(0,
|
|
129
|
+
(0, import_addMinimalViableSchemaToRequestDocument.extractMinimalViableSchemaForRequestDocument)(import_swapi_schema.default, parsedQuery);
|
|
139
130
|
});
|
|
140
131
|
function main() {
|
|
141
132
|
return __async(this, null, function* () {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/benchmarks/index.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from \"fs\";\nimport path from \"path\";\nimport NiceBenchmark from \"./nice-benchmark\";\nimport schema from \"./swapi-schema\";\nimport resolvers from \"./swapi-schema/resolvers\";\nimport models from \"./swapi-schema/models\";\nimport {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gBAAe;AACf,kBAAiB;AACjB,4BAA0B;AAC1B,0BAAmB;AACnB,uBAAsB;AACtB,oBAAmB;AACnB,
|
|
6
|
-
"names": ["fs", "path", "schema", "NiceBenchmark", "
|
|
4
|
+
"sourcesContent": ["import fs from \"fs\";\nimport path from \"path\";\nimport NiceBenchmark from \"./nice-benchmark\";\nimport schema from \"./swapi-schema\";\nimport resolvers from \"./swapi-schema/resolvers\";\nimport models from \"./swapi-schema/models\";\nimport {\n execute as graphqlExecute,\n parse,\n // experimentalExecuteIncrementally as graphqlExecute,\n} from \"graphql\";\nimport { compileQuery, isCompiledQuery } from \"graphql-jit\";\nimport { executeWithoutSchema as supermassiveExecute } from \"../executeWithoutSchema\";\nimport { UserResolvers } from \"../types\";\nimport { extractMinimalViableSchemaForRequestDocument } from \"../utilities/addMinimalViableSchemaToRequestDocument\";\n\nconst query = fs.readFileSync(\n path.join(__dirname, \"./fixtures/query1.graphql\"),\n {\n encoding: \"utf-8\",\n },\n);\n\nconst parsedQuery = parse(query);\n\nconst compiledQuery = compileQuery(schema, parsedQuery);\n\nconst schemaFragment = extractMinimalViableSchemaForRequestDocument(\n schema,\n parsedQuery,\n);\n\nconst queryRunningSuite = new NiceBenchmark(\"Query Running\");\nqueryRunningSuite.add(\"graphql-js - string queries\", async () => {\n const result = await graphqlExecute({\n schema,\n document: parse(query),\n contextValue: { models },\n });\n if (result.errors || !result.data) {\n throw new Error(\"Stuff ain't executing\");\n }\n});\nqueryRunningSuite.add(\"graphql-js - parsed queries\", async () => {\n const result = await graphqlExecute({\n schema,\n document: parsedQuery,\n contextValue: { models },\n });\n if (result.errors || !result.data) {\n throw new Error(\"Stuff ain't executing\");\n }\n});\nqueryRunningSuite.add(\"graphql-jit - uncompiled\", async () => {\n const freshCompiledQuery = compileQuery(schema, parsedQuery);\n if (isCompiledQuery(freshCompiledQuery)) {\n const result = await freshCompiledQuery.query({}, { models }, {});\n if (result.errors || !result.data) {\n throw new Error(\"Stuff ain't executing\");\n }\n } else {\n throw new Error(\"Wrong query\");\n }\n});\nqueryRunningSuite.add(\"graphql-jit - precompiled\", async () => {\n if (isCompiledQuery(compiledQuery)) {\n const result = await compiledQuery.query({}, { models }, {});\n if (result.errors || !result.data) {\n throw new Error(\"Stuff ain't executing\");\n }\n } else {\n throw new Error(\"Wrong query\");\n }\n});\nqueryRunningSuite.add(\"supermassive - runtime schemaless\", async () => {\n const result = await supermassiveExecute({\n resolvers: resolvers as UserResolvers,\n schemaFragment,\n document: parsedQuery,\n contextValue: { models },\n });\n if (\"data\" in result && (result.errors || !result.data)) {\n throw new Error(\"Stuff ain't executing\");\n }\n});\n\nconst queryParsingSuite = new NiceBenchmark(\"Query parsing\");\nqueryParsingSuite.add(\"graphql-js\", async () => {\n parse(query);\n});\n\nconst queryCompilingSuite = new NiceBenchmark(\"Query compiling\");\nqueryCompilingSuite.add(\"graphql-jit\", async () => {\n await compileQuery(schema, parsedQuery);\n});\n\nconst queryAnnotationSuite = new NiceBenchmark(\"Query annotation\");\nqueryAnnotationSuite.add(\"supermassive\", () => {\n extractMinimalViableSchemaForRequestDocument(schema, parsedQuery);\n});\n\nasync function main() {\n await queryCompilingSuite.run();\n await queryParsingSuite.run();\n await queryAnnotationSuite.run();\n await queryRunningSuite.run();\n}\n\nmain();\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gBAAe;AACf,kBAAiB;AACjB,4BAA0B;AAC1B,0BAAmB;AACnB,uBAAsB;AACtB,oBAAmB;AACnB,qBAIO;AACP,yBAA8C;AAC9C,kCAA4D;AAE5D,qDAA6D;AAE7D,MAAM,QAAQ,UAAAA,QAAG;AAAA,EACf,YAAAC,QAAK,KAAK,WAAW,2BAA2B;AAAA,EAChD;AAAA,IACE,UAAU;AAAA,EACZ;AACF;AAEA,MAAM,kBAAc,sBAAM,KAAK;AAE/B,MAAM,oBAAgB,iCAAa,oBA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AAM,IAAI,MAAM,uBAAuB;AAAA,IACzC;AAAA,EACF,OAAO;AACL,UAAM,IAAI,MAAM,aAAa;AAAA,EAC/B;AACF,EAAC;AACD,kBAAkB,IAAI,qCAAqC,MAAY;AACrE,QAAM,SAAS,UAAM,4BAAAC,sBAAoB;AAAA,IACvC,WAAW,iBAAAC;AAAA,IACX;AAAA,IACA,UAAU;AAAA,IACV,cAAc,EAAE,sBAAAF,QAAO;AAAA,EACzB,CAAC;AACD,MAAI,UAAU,WAAW,OAAO,UAAU,CAAC,OAAO,OAAO;AACvD,UAAM,IAAI,MAAM,uBAAuB;AAAA,EACzC;AACF,EAAC;AAED,MAAM,oBAAoB,IAAI,sBAAAF,QAAc,eAAe;AAC3D,kBAAkB,IAAI,cAAc,MAAY;AAC9C,4BAAM,KAAK;AACb,EAAC;AAED,MAAM,sBAAsB,IAAI,sBAAAA,QAAc,iBAAiB;AAC/D,oBAAoB,IAAI,eAAe,MAAY;AACjD,YAAM,iCAAa,oBAAAD,SAAQ,WAAW;AACxC,EAAC;AAED,MAAM,uBAAuB,IAAI,sBAAAC,QAAc,kBAAkB;AACjE,qBAAqB,IAAI,gBAAgB,MAAM;AAC7C,mGAA6C,oBAAAD,SAAQ,WAAW;AAClE,CAAC;AAED,SAAe,OAAO;AAAA;AACpB,UAAM,oBAAoB,IAAI;AAC9B,UAAM,kBAAkB,IAAI;AAC5B,UAAM,qBAAqB,IAAI;AAC/B,UAAM,kBAAkB,IAAI;AAAA,EAC9B;AAAA;AAEA,KAAK;",
|
|
6
|
+
"names": ["fs", "path", "schema", "NiceBenchmark", "graphqlExecute", "models", "supermassiveExecute", "resolvers"]
|
|
7
7
|
}
|
package/lib/benchmarks/index.mjs
CHANGED
|
@@ -31,16 +31,12 @@ import schema from "./swapi-schema/index.mjs";
|
|
|
31
31
|
import resolvers from "./swapi-schema/resolvers.mjs";
|
|
32
32
|
import models from "./swapi-schema/models.mjs";
|
|
33
33
|
import {
|
|
34
|
-
graphql,
|
|
35
34
|
execute as graphqlExecute,
|
|
36
|
-
parse
|
|
37
|
-
isInputType
|
|
35
|
+
parse
|
|
38
36
|
} from "graphql";
|
|
39
37
|
import { compileQuery, isCompiledQuery } from "graphql-jit";
|
|
40
38
|
import { executeWithoutSchema as supermassiveExecute } from "../executeWithoutSchema.mjs";
|
|
41
|
-
import {
|
|
42
|
-
import { extractImplicitTypes } from "../extractImplicitTypesRuntime.mjs";
|
|
43
|
-
import { specifiedScalars } from "../values.mjs";
|
|
39
|
+
import { extractMinimalViableSchemaForRequestDocument } from "../utilities/addMinimalViableSchemaToRequestDocument.mjs";
|
|
44
40
|
var require_benchmarks = __commonJS({
|
|
45
41
|
"src/benchmarks/index.ts"(exports) {
|
|
46
42
|
var query = fs.readFileSync(
|
|
@@ -51,12 +47,15 @@ var require_benchmarks = __commonJS({
|
|
|
51
47
|
);
|
|
52
48
|
var parsedQuery = parse(query);
|
|
53
49
|
var compiledQuery = compileQuery(schema, parsedQuery);
|
|
54
|
-
var
|
|
50
|
+
var schemaFragment = extractMinimalViableSchemaForRequestDocument(
|
|
51
|
+
schema,
|
|
52
|
+
parsedQuery
|
|
53
|
+
);
|
|
55
54
|
var queryRunningSuite = new NiceBenchmark("Query Running");
|
|
56
55
|
queryRunningSuite.add("graphql-js - string queries", () => __async(exports, null, function* () {
|
|
57
|
-
const result = yield
|
|
56
|
+
const result = yield graphqlExecute({
|
|
58
57
|
schema,
|
|
59
|
-
|
|
58
|
+
document: parse(query),
|
|
60
59
|
contextValue: { models }
|
|
61
60
|
});
|
|
62
61
|
if (result.errors || !result.data) {
|
|
@@ -95,23 +94,13 @@ var require_benchmarks = __commonJS({
|
|
|
95
94
|
}
|
|
96
95
|
}));
|
|
97
96
|
queryRunningSuite.add("supermassive - runtime schemaless", () => __async(exports, null, function* () {
|
|
98
|
-
let extractedResolvers = {};
|
|
99
|
-
const getTypeByName = (name) => {
|
|
100
|
-
const type = specifiedScalars[name] || extractedResolvers[name];
|
|
101
|
-
if (isInputType(type)) {
|
|
102
|
-
return type;
|
|
103
|
-
} else {
|
|
104
|
-
throw new Error("Invalid type");
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
extractedResolvers = extractImplicitTypes(parsedQuery, getTypeByName);
|
|
108
97
|
const result = yield supermassiveExecute({
|
|
109
98
|
resolvers,
|
|
110
|
-
|
|
111
|
-
document:
|
|
99
|
+
schemaFragment,
|
|
100
|
+
document: parsedQuery,
|
|
112
101
|
contextValue: { models }
|
|
113
102
|
});
|
|
114
|
-
if (result.errors || !result.data) {
|
|
103
|
+
if ("data" in result && (result.errors || !result.data)) {
|
|
115
104
|
throw new Error("Stuff ain't executing");
|
|
116
105
|
}
|
|
117
106
|
}));
|
|
@@ -125,7 +114,7 @@ var require_benchmarks = __commonJS({
|
|
|
125
114
|
}));
|
|
126
115
|
var queryAnnotationSuite = new NiceBenchmark("Query annotation");
|
|
127
116
|
queryAnnotationSuite.add("supermassive", () => {
|
|
128
|
-
|
|
117
|
+
extractMinimalViableSchemaForRequestDocument(schema, parsedQuery);
|
|
129
118
|
});
|
|
130
119
|
function main() {
|
|
131
120
|
return __async(this, null, function* () {
|