@graphitation/supermassive 0.8.3 → 1.0.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/CHANGELOG.md +26 -2
- package/README.md +24 -29
- package/lib/ast/TypedAST.js +14 -2
- package/lib/ast/addTypesToRequestDocument.js +23 -23
- package/lib/ast/addTypesToRequestDocument.mjs +8 -5
- package/lib/benchmarks/index.js +33 -36
- package/lib/benchmarks/index.mjs +101 -92
- package/lib/benchmarks/nice-benchmark.js +14 -18
- package/lib/benchmarks/nice-benchmark.mjs +2 -3
- package/lib/benchmarks/swapi-schema/index.js +19 -20
- package/lib/benchmarks/swapi-schema/index.mjs +4 -4
- package/lib/benchmarks/swapi-schema/models.js +16 -17
- package/lib/benchmarks/swapi-schema/models.mjs +1 -1
- package/lib/benchmarks/swapi-schema/resolvers.js +65 -66
- package/lib/benchmarks/swapi-schema/resolvers.mjs +51 -48
- package/lib/bin/supermassive.js +23 -24
- package/lib/bin/supermassive.mjs +6 -6
- package/lib/collectFields.js +23 -27
- package/lib/collectFields.mjs +10 -10
- package/lib/definition.js +15 -19
- package/lib/definition.mjs +2 -2
- package/lib/directives.js +21 -25
- package/lib/directives.mjs +7 -7
- package/lib/executeWithSchema.js +15 -19
- package/lib/executeWithSchema.mjs +1 -1
- package/lib/executeWithoutSchema.js +37 -41
- package/lib/executeWithoutSchema.mjs +22 -22
- package/lib/extractImplicitTypesRuntime.js +17 -21
- package/lib/extractImplicitTypesRuntime.mjs +3 -3
- package/lib/extractImplicitTypesToTypescript.js +16 -17
- package/lib/extractImplicitTypesToTypescript.mjs +1 -1
- package/lib/extractors/index.d.ts +2 -0
- package/lib/extractors/index.d.ts.map +1 -0
- package/lib/extractors/index.js +23 -0
- package/lib/extractors/index.mjs +5 -0
- package/lib/index.js +21 -25
- package/lib/index.mjs +8 -8
- package/lib/jsutils/Maybe.js +14 -2
- package/lib/jsutils/ObjMap.js +14 -2
- package/lib/jsutils/Path.js +17 -5
- package/lib/jsutils/Path.mjs +1 -1
- package/lib/jsutils/PromiseOrValue.js +14 -2
- package/lib/jsutils/devAssert.js +16 -4
- package/lib/jsutils/didYouMean.js +16 -4
- package/lib/jsutils/identityFunc.js +16 -4
- package/lib/jsutils/inspect.js +16 -4
- package/lib/jsutils/instanceOf.js +14 -18
- package/lib/jsutils/instanceOf.mjs +1 -1
- package/lib/jsutils/invariant.js +16 -4
- package/lib/jsutils/isAsyncIterable.js +16 -4
- package/lib/jsutils/isIterableObject.js +16 -4
- package/lib/jsutils/isObjectLike.js +16 -4
- package/lib/jsutils/isPromise.js +16 -4
- package/lib/jsutils/keyMap.js +17 -5
- package/lib/jsutils/keyMap.mjs +1 -1
- package/lib/jsutils/keyValMap.js +17 -5
- package/lib/jsutils/keyValMap.mjs +1 -1
- package/lib/jsutils/mapValue.js +17 -5
- package/lib/jsutils/mapValue.mjs +1 -1
- package/lib/jsutils/memoize3.js +19 -7
- package/lib/jsutils/memoize3.mjs +3 -3
- package/lib/jsutils/naturalCompare.js +16 -4
- package/lib/jsutils/printPathArray.js +16 -4
- package/lib/jsutils/promiseForObject.js +17 -5
- package/lib/jsutils/promiseForObject.mjs +1 -1
- package/lib/jsutils/promiseReduce.js +14 -18
- package/lib/jsutils/promiseReduce.mjs +1 -1
- package/lib/jsutils/suggestionList.js +15 -19
- package/lib/jsutils/suggestionList.mjs +2 -2
- package/lib/jsutils/toObjMap.js +17 -5
- package/lib/jsutils/toObjMap.mjs +1 -1
- package/lib/subscribeWithSchema.js +15 -19
- package/lib/subscribeWithSchema.mjs +1 -1
- package/lib/subscribeWithoutSchema.js +26 -30
- package/lib/subscribeWithoutSchema.mjs +11 -11
- package/lib/transforms/annotateDocumentGraphQLTransform.js +15 -19
- package/lib/transforms/annotateDocumentGraphQLTransform.mjs +1 -1
- package/lib/transforms/transformerTestUtils.js +24 -25
- package/lib/transforms/transformerTestUtils.mjs +12 -16
- package/lib/types.js +14 -2
- package/lib/utilities/mapAsyncIterator.js +18 -6
- package/lib/utilities/mapAsyncIterator.mjs +2 -2
- package/lib/utilities/mergeResolvers.js +20 -9
- package/lib/utilities/mergeResolvers.mjs +5 -5
- package/lib/utilities/typeNameFromAST.js +14 -18
- package/lib/utilities/typeNameFromAST.mjs +1 -1
- package/lib/values.js +19 -23
- package/lib/values.mjs +5 -5
- package/package.json +13 -8
- package/.eslintcache +0 -1
- package/lib/benchmarks/swapi-schema/__generated__/schema.d.ts +0 -3
- package/lib/benchmarks/swapi-schema/__generated__/schema.d.ts.map +0 -1
- package/lib/benchmarks/swapi-schema/__generated__/schema.js +0 -41
- package/lib/benchmarks/swapi-schema/__generated__/schema.mjs +0 -19
package/lib/bin/supermassive.js
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
7
|
var __export = (target, all) => {
|
|
9
8
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
10
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
16
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
17
|
+
return to;
|
|
22
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
21
|
var __async = (__this, __arguments, generator) => {
|
|
24
22
|
return new Promise((resolve, reject) => {
|
|
25
23
|
var fulfilled = (value) => {
|
|
@@ -40,16 +38,17 @@ var __async = (__this, __arguments, generator) => {
|
|
|
40
38
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
41
39
|
});
|
|
42
40
|
};
|
|
43
|
-
|
|
44
|
-
__export(
|
|
41
|
+
var supermassive_exports = {};
|
|
42
|
+
__export(supermassive_exports, {
|
|
45
43
|
supermassive: () => supermassive
|
|
46
44
|
});
|
|
47
|
-
|
|
48
|
-
var
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var
|
|
45
|
+
module.exports = __toCommonJS(supermassive_exports);
|
|
46
|
+
var import_path = __toESM(require("path"));
|
|
47
|
+
var import_promises = __toESM(require("fs/promises"));
|
|
48
|
+
var import_typescript = __toESM(require("typescript"));
|
|
49
|
+
var import_commander = require("commander");
|
|
50
|
+
var import_extractImplicitTypesToTypescript = require("../extractImplicitTypesToTypescript");
|
|
51
|
+
var import_graphql = require("graphql");
|
|
53
52
|
function supermassive() {
|
|
54
53
|
const command = new import_commander.Command();
|
|
55
54
|
command.name("extract-schema").argument("<files...>").description("extract implicit resolvers to a ts file from graphql typedefs").action((files) => __async(this, null, function* () {
|
|
@@ -70,14 +69,14 @@ function typeDefsToImplicitResolversImpl(files) {
|
|
|
70
69
|
if (!stat.isFile) {
|
|
71
70
|
throw new Error(`Invalid file ${file}`);
|
|
72
71
|
}
|
|
73
|
-
const content = yield import_promises.default.readFile(fullPath, {encoding: "utf-8"});
|
|
72
|
+
const content = yield import_promises.default.readFile(fullPath, { encoding: "utf-8" });
|
|
74
73
|
const document = (0, import_graphql.parse)(content);
|
|
75
74
|
const tsContents = (0, import_extractImplicitTypesToTypescript.extractImplicitTypesToTypescript)(document);
|
|
76
75
|
const tsDir = import_path.default.join(import_path.default.dirname(fullPath), "__generated__");
|
|
77
|
-
yield import_promises.default.mkdir(tsDir, {recursive: true});
|
|
76
|
+
yield import_promises.default.mkdir(tsDir, { recursive: true });
|
|
78
77
|
const tsFileName = import_path.default.join(tsDir, import_path.default.basename(fullPath, import_path.default.extname(fullPath)) + ".ts");
|
|
79
78
|
const printer = import_typescript.default.createPrinter();
|
|
80
|
-
yield import_promises.default.writeFile(tsFileName, printer.printNode(import_typescript.default.EmitHint.SourceFile, tsContents, tsContents), {encoding: "utf-8"});
|
|
79
|
+
yield import_promises.default.writeFile(tsFileName, printer.printNode(import_typescript.default.EmitHint.SourceFile, tsContents, tsContents), { encoding: "utf-8" });
|
|
81
80
|
}
|
|
82
81
|
});
|
|
83
82
|
}
|
package/lib/bin/supermassive.mjs
CHANGED
|
@@ -23,9 +23,9 @@ var __async = (__this, __arguments, generator) => {
|
|
|
23
23
|
import path from "path";
|
|
24
24
|
import fs from "fs/promises";
|
|
25
25
|
import ts from "typescript";
|
|
26
|
-
import {program, Command} from "commander";
|
|
27
|
-
import {extractImplicitTypesToTypescript} from "../extractImplicitTypesToTypescript.mjs";
|
|
28
|
-
import {parse} from "graphql";
|
|
26
|
+
import { program, Command } from "commander";
|
|
27
|
+
import { extractImplicitTypesToTypescript } from "../extractImplicitTypesToTypescript.mjs";
|
|
28
|
+
import { parse } from "graphql";
|
|
29
29
|
function supermassive() {
|
|
30
30
|
const command = new Command();
|
|
31
31
|
command.name("extract-schema").argument("<files...>").description("extract implicit resolvers to a ts file from graphql typedefs").action((files) => __async(this, null, function* () {
|
|
@@ -46,14 +46,14 @@ function typeDefsToImplicitResolversImpl(files) {
|
|
|
46
46
|
if (!stat.isFile) {
|
|
47
47
|
throw new Error(`Invalid file ${file}`);
|
|
48
48
|
}
|
|
49
|
-
const content = yield fs.readFile(fullPath, {encoding: "utf-8"});
|
|
49
|
+
const content = yield fs.readFile(fullPath, { encoding: "utf-8" });
|
|
50
50
|
const document = parse(content);
|
|
51
51
|
const tsContents = extractImplicitTypesToTypescript(document);
|
|
52
52
|
const tsDir = path.join(path.dirname(fullPath), "__generated__");
|
|
53
|
-
yield fs.mkdir(tsDir, {recursive: true});
|
|
53
|
+
yield fs.mkdir(tsDir, { recursive: true });
|
|
54
54
|
const tsFileName = path.join(tsDir, path.basename(fullPath, path.extname(fullPath)) + ".ts");
|
|
55
55
|
const printer = ts.createPrinter();
|
|
56
|
-
yield fs.writeFile(tsFileName, printer.printNode(ts.EmitHint.SourceFile, tsContents, tsContents), {encoding: "utf-8"});
|
|
56
|
+
yield fs.writeFile(tsFileName, printer.printNode(ts.EmitHint.SourceFile, tsContents, tsContents), { encoding: "utf-8" });
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
}
|
package/lib/collectFields.js
CHANGED
|
@@ -1,34 +1,30 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
5
|
var __export = (target, all) => {
|
|
9
6
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
8
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
14
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
15
|
+
return to;
|
|
22
16
|
};
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var collectFields_exports = {};
|
|
19
|
+
__export(collectFields_exports, {
|
|
25
20
|
collectFields: () => collectFields
|
|
26
21
|
});
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var
|
|
22
|
+
module.exports = __toCommonJS(collectFields_exports);
|
|
23
|
+
var import_graphql = require("graphql");
|
|
24
|
+
var import_values = require("./values");
|
|
25
|
+
var import_directives = require("./directives");
|
|
26
|
+
var import_typeNameFromAST = require("./utilities/typeNameFromAST");
|
|
27
|
+
var import_definition = require("./definition");
|
|
32
28
|
function collectFields(resolvers, fragments, variableValues, runtimeTypeName, selectionSet, fields, visitedFragmentNames) {
|
|
33
29
|
for (const selection of selectionSet.selections) {
|
|
34
30
|
switch (selection.kind) {
|
|
@@ -93,7 +89,7 @@ function doesFragmentConditionMatch(fragment, typeName, resolvers) {
|
|
|
93
89
|
if (conditionalType === typeName) {
|
|
94
90
|
return true;
|
|
95
91
|
}
|
|
96
|
-
const subTypes = getSubTypes(resolvers, new Set(), conditionalType);
|
|
92
|
+
const subTypes = getSubTypes(resolvers, /* @__PURE__ */ new Set(), conditionalType);
|
|
97
93
|
return subTypes.has(typeName);
|
|
98
94
|
}
|
|
99
95
|
function getSubTypes(resolvers, abstractTypes, conditionalType) {
|
|
@@ -101,22 +97,22 @@ function getSubTypes(resolvers, abstractTypes, conditionalType) {
|
|
|
101
97
|
if ((0, import_definition.isInterfaceResolverType)(resolver)) {
|
|
102
98
|
const result = resolver.__implementedBy.reduce((acc, item) => {
|
|
103
99
|
if (!abstractTypes.has(item)) {
|
|
104
|
-
const newTypes = new Set([...abstractTypes, item]);
|
|
100
|
+
const newTypes = /* @__PURE__ */ new Set([...abstractTypes, item]);
|
|
105
101
|
acc.push(...abstractTypes, ...getSubTypes(resolvers, newTypes, item));
|
|
106
102
|
}
|
|
107
103
|
return acc;
|
|
108
104
|
}, []);
|
|
109
|
-
return new Set([...result]);
|
|
105
|
+
return /* @__PURE__ */ new Set([...result]);
|
|
110
106
|
}
|
|
111
107
|
if ((0, import_definition.isUnionResolverType)(resolver)) {
|
|
112
108
|
const result = resolver.__types.reduce((acc, item) => {
|
|
113
109
|
if (!abstractTypes.has(item)) {
|
|
114
|
-
const newTypes = new Set([...abstractTypes, item]);
|
|
110
|
+
const newTypes = /* @__PURE__ */ new Set([...abstractTypes, item]);
|
|
115
111
|
acc.push(...abstractTypes, ...getSubTypes(resolvers, newTypes, item));
|
|
116
112
|
}
|
|
117
113
|
return acc;
|
|
118
114
|
}, []);
|
|
119
|
-
return new Set([...result]);
|
|
115
|
+
return /* @__PURE__ */ new Set([...result]);
|
|
120
116
|
}
|
|
121
117
|
return abstractTypes;
|
|
122
118
|
}
|
package/lib/collectFields.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// src/collectFields.ts
|
|
2
|
-
import {Kind} from "graphql";
|
|
3
|
-
import {getDirectiveValues} from "./values.mjs";
|
|
4
|
-
import {GraphQLSkipDirective, GraphQLIncludeDirective} from "./directives.mjs";
|
|
5
|
-
import {typeNameFromAST} from "./utilities/typeNameFromAST.mjs";
|
|
6
|
-
import {isUnionResolverType, isInterfaceResolverType} from "./definition.mjs";
|
|
2
|
+
import { Kind } from "graphql";
|
|
3
|
+
import { getDirectiveValues } from "./values.mjs";
|
|
4
|
+
import { GraphQLSkipDirective, GraphQLIncludeDirective } from "./directives.mjs";
|
|
5
|
+
import { typeNameFromAST } from "./utilities/typeNameFromAST.mjs";
|
|
6
|
+
import { isUnionResolverType, isInterfaceResolverType } from "./definition.mjs";
|
|
7
7
|
function collectFields(resolvers, fragments, variableValues, runtimeTypeName, selectionSet, fields, visitedFragmentNames) {
|
|
8
8
|
for (const selection of selectionSet.selections) {
|
|
9
9
|
switch (selection.kind) {
|
|
@@ -68,7 +68,7 @@ function doesFragmentConditionMatch(fragment, typeName, resolvers) {
|
|
|
68
68
|
if (conditionalType === typeName) {
|
|
69
69
|
return true;
|
|
70
70
|
}
|
|
71
|
-
const subTypes = getSubTypes(resolvers, new Set(), conditionalType);
|
|
71
|
+
const subTypes = getSubTypes(resolvers, /* @__PURE__ */ new Set(), conditionalType);
|
|
72
72
|
return subTypes.has(typeName);
|
|
73
73
|
}
|
|
74
74
|
function getSubTypes(resolvers, abstractTypes, conditionalType) {
|
|
@@ -76,22 +76,22 @@ function getSubTypes(resolvers, abstractTypes, conditionalType) {
|
|
|
76
76
|
if (isInterfaceResolverType(resolver)) {
|
|
77
77
|
const result = resolver.__implementedBy.reduce((acc, item) => {
|
|
78
78
|
if (!abstractTypes.has(item)) {
|
|
79
|
-
const newTypes = new Set([...abstractTypes, item]);
|
|
79
|
+
const newTypes = /* @__PURE__ */ new Set([...abstractTypes, item]);
|
|
80
80
|
acc.push(...abstractTypes, ...getSubTypes(resolvers, newTypes, item));
|
|
81
81
|
}
|
|
82
82
|
return acc;
|
|
83
83
|
}, []);
|
|
84
|
-
return new Set([...result]);
|
|
84
|
+
return /* @__PURE__ */ new Set([...result]);
|
|
85
85
|
}
|
|
86
86
|
if (isUnionResolverType(resolver)) {
|
|
87
87
|
const result = resolver.__types.reduce((acc, item) => {
|
|
88
88
|
if (!abstractTypes.has(item)) {
|
|
89
|
-
const newTypes = new Set([...abstractTypes, item]);
|
|
89
|
+
const newTypes = /* @__PURE__ */ new Set([...abstractTypes, item]);
|
|
90
90
|
acc.push(...abstractTypes, ...getSubTypes(resolvers, newTypes, item));
|
|
91
91
|
}
|
|
92
92
|
return acc;
|
|
93
93
|
}, []);
|
|
94
|
-
return new Set([...result]);
|
|
94
|
+
return /* @__PURE__ */ new Set([...result]);
|
|
95
95
|
}
|
|
96
96
|
return abstractTypes;
|
|
97
97
|
}
|
package/lib/definition.js
CHANGED
|
@@ -1,34 +1,30 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
5
|
var __export = (target, all) => {
|
|
9
6
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
8
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
14
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
15
|
+
return to;
|
|
22
16
|
};
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var definition_exports = {};
|
|
19
|
+
__export(definition_exports, {
|
|
25
20
|
argsToArgsConfig: () => argsToArgsConfig,
|
|
26
21
|
defineArguments: () => defineArguments,
|
|
27
22
|
isInterfaceResolverType: () => isInterfaceResolverType,
|
|
28
23
|
isUnionResolverType: () => isUnionResolverType
|
|
29
24
|
});
|
|
30
|
-
|
|
31
|
-
var
|
|
25
|
+
module.exports = __toCommonJS(definition_exports);
|
|
26
|
+
var import_toObjMap = require("./jsutils/toObjMap");
|
|
27
|
+
var import_keyValMap = require("./jsutils/keyValMap");
|
|
32
28
|
function defineArguments(config) {
|
|
33
29
|
return Object.entries(config).map(([argName, argConfig]) => ({
|
|
34
30
|
name: argName,
|
package/lib/definition.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/definition.ts
|
|
2
|
-
import {toObjMap} from "./jsutils/toObjMap.mjs";
|
|
3
|
-
import {keyValMap} from "./jsutils/keyValMap.mjs";
|
|
2
|
+
import { toObjMap } from "./jsutils/toObjMap.mjs";
|
|
3
|
+
import { keyValMap } from "./jsutils/keyValMap.mjs";
|
|
4
4
|
function defineArguments(config) {
|
|
5
5
|
return Object.entries(config).map(([argName, argConfig]) => ({
|
|
6
6
|
name: argName,
|
package/lib/directives.js
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
5
|
var __export = (target, all) => {
|
|
9
6
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
8
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
14
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
15
|
+
return to;
|
|
22
16
|
};
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var directives_exports = {};
|
|
19
|
+
__export(directives_exports, {
|
|
25
20
|
DEFAULT_DEPRECATION_REASON: () => DEFAULT_DEPRECATION_REASON,
|
|
26
21
|
GraphQLDeprecatedDirective: () => GraphQLDeprecatedDirective,
|
|
27
22
|
GraphQLDirective: () => GraphQLDirective,
|
|
@@ -33,13 +28,14 @@ __export(exports, {
|
|
|
33
28
|
isSpecifiedDirective: () => isSpecifiedDirective,
|
|
34
29
|
specifiedDirectives: () => specifiedDirectives
|
|
35
30
|
});
|
|
36
|
-
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
31
|
+
module.exports = __toCommonJS(directives_exports);
|
|
32
|
+
var import_graphql = require("graphql");
|
|
33
|
+
var import_inspect = require("./jsutils/inspect");
|
|
34
|
+
var import_toObjMap = require("./jsutils/toObjMap");
|
|
35
|
+
var import_devAssert = require("./jsutils/devAssert");
|
|
36
|
+
var import_instanceOf = require("./jsutils/instanceOf");
|
|
37
|
+
var import_isObjectLike = require("./jsutils/isObjectLike");
|
|
38
|
+
var import_definition = require("./definition");
|
|
43
39
|
function isDirective(directive) {
|
|
44
40
|
return (0, import_instanceOf.instanceOf)(directive, GraphQLDirective);
|
|
45
41
|
}
|
|
@@ -151,5 +147,5 @@ const specifiedDirectives = Object.freeze([
|
|
|
151
147
|
GraphQLSpecifiedByDirective
|
|
152
148
|
]);
|
|
153
149
|
function isSpecifiedDirective(directive) {
|
|
154
|
-
return specifiedDirectives.some(({name}) => name === directive.name);
|
|
150
|
+
return specifiedDirectives.some(({ name }) => name === directive.name);
|
|
155
151
|
}
|
package/lib/directives.mjs
CHANGED
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
GraphQLNonNull,
|
|
6
6
|
DirectiveLocation
|
|
7
7
|
} from "graphql";
|
|
8
|
-
import {inspect} from "./jsutils/inspect.mjs";
|
|
9
|
-
import {toObjMap} from "./jsutils/toObjMap.mjs";
|
|
10
|
-
import {devAssert} from "./jsutils/devAssert.mjs";
|
|
11
|
-
import {instanceOf} from "./jsutils/instanceOf.mjs";
|
|
12
|
-
import {isObjectLike} from "./jsutils/isObjectLike.mjs";
|
|
13
|
-
import {defineArguments, argsToArgsConfig} from "./definition.mjs";
|
|
8
|
+
import { inspect } from "./jsutils/inspect.mjs";
|
|
9
|
+
import { toObjMap } from "./jsutils/toObjMap.mjs";
|
|
10
|
+
import { devAssert } from "./jsutils/devAssert.mjs";
|
|
11
|
+
import { instanceOf } from "./jsutils/instanceOf.mjs";
|
|
12
|
+
import { isObjectLike } from "./jsutils/isObjectLike.mjs";
|
|
13
|
+
import { defineArguments, argsToArgsConfig } from "./definition.mjs";
|
|
14
14
|
function isDirective(directive) {
|
|
15
15
|
return instanceOf(directive, GraphQLDirective);
|
|
16
16
|
}
|
|
@@ -122,7 +122,7 @@ var specifiedDirectives = Object.freeze([
|
|
|
122
122
|
GraphQLSpecifiedByDirective
|
|
123
123
|
]);
|
|
124
124
|
function isSpecifiedDirective(directive) {
|
|
125
|
-
return specifiedDirectives.some(({name}) => name === directive.name);
|
|
125
|
+
return specifiedDirectives.some(({ name }) => name === directive.name);
|
|
126
126
|
}
|
|
127
127
|
export {
|
|
128
128
|
DEFAULT_DEPRECATION_REASON,
|
package/lib/executeWithSchema.js
CHANGED
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
5
|
var __export = (target, all) => {
|
|
9
6
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
8
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
14
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
15
|
+
return to;
|
|
22
16
|
};
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var executeWithSchema_exports = {};
|
|
19
|
+
__export(executeWithSchema_exports, {
|
|
25
20
|
executeWithSchema: () => executeWithSchema
|
|
26
21
|
});
|
|
27
|
-
|
|
28
|
-
var
|
|
22
|
+
module.exports = __toCommonJS(executeWithSchema_exports);
|
|
23
|
+
var import_graphql = require("graphql");
|
|
24
|
+
var import_index = require("./index");
|
|
29
25
|
function executeWithSchema({
|
|
30
26
|
typeDefs,
|
|
31
27
|
resolvers,
|
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
5
|
var __export = (target, all) => {
|
|
9
6
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
8
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
14
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
15
|
+
return to;
|
|
22
16
|
};
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var executeWithoutSchema_exports = {};
|
|
19
|
+
__export(executeWithoutSchema_exports, {
|
|
25
20
|
assertValidExecutionArguments: () => assertValidExecutionArguments,
|
|
26
21
|
buildExecutionContext: () => buildExecutionContext,
|
|
27
22
|
buildResolveInfo: () => buildResolveInfo,
|
|
@@ -30,21 +25,22 @@ __export(exports, {
|
|
|
30
25
|
executeWithoutSchema: () => executeWithoutSchema,
|
|
31
26
|
getOperationRootTypeName: () => getOperationRootTypeName
|
|
32
27
|
});
|
|
33
|
-
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
var
|
|
28
|
+
module.exports = __toCommonJS(executeWithoutSchema_exports);
|
|
29
|
+
var import_graphql = require("graphql");
|
|
30
|
+
var import_collectFields = require("./collectFields");
|
|
31
|
+
var import_devAssert = require("./jsutils/devAssert");
|
|
32
|
+
var import_inspect = require("./jsutils/inspect");
|
|
33
|
+
var import_invariant = require("./jsutils/invariant");
|
|
34
|
+
var import_isIterableObject = require("./jsutils/isIterableObject");
|
|
35
|
+
var import_isObjectLike = require("./jsutils/isObjectLike");
|
|
36
|
+
var import_isPromise = require("./jsutils/isPromise");
|
|
37
|
+
var import_Path = require("./jsutils/Path");
|
|
38
|
+
var import_promiseForObject = require("./jsutils/promiseForObject");
|
|
39
|
+
var import_promiseReduce = require("./jsutils/promiseReduce");
|
|
40
|
+
var import_definition = require("./definition");
|
|
41
|
+
var import_mergeResolvers = require("./utilities/mergeResolvers");
|
|
42
|
+
var import_typeNameFromAST = require("./utilities/typeNameFromAST");
|
|
43
|
+
var import_values = require("./values");
|
|
48
44
|
function executeWithoutSchema(args) {
|
|
49
45
|
const {
|
|
50
46
|
resolvers,
|
|
@@ -61,7 +57,7 @@ function executeWithoutSchema(args) {
|
|
|
61
57
|
assertValidExecutionArguments(document, variableValues);
|
|
62
58
|
const exeContext = buildExecutionContext(combinedResolvers, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver);
|
|
63
59
|
if (!("resolvers" in exeContext)) {
|
|
64
|
-
return {errors: exeContext};
|
|
60
|
+
return { errors: exeContext };
|
|
65
61
|
} else {
|
|
66
62
|
const data = executeOperation(exeContext, exeContext.operation, rootValue);
|
|
67
63
|
return buildResponse(exeContext, data);
|
|
@@ -71,7 +67,7 @@ function buildResponse(exeContext, data) {
|
|
|
71
67
|
if ((0, import_isPromise.isPromise)(data)) {
|
|
72
68
|
return data.then((resolved) => buildResponse(exeContext, resolved));
|
|
73
69
|
}
|
|
74
|
-
return exeContext.errors.length === 0 ? {data} : {errors: exeContext.errors, data};
|
|
70
|
+
return exeContext.errors.length === 0 ? { data } : { errors: exeContext.errors, data };
|
|
75
71
|
}
|
|
76
72
|
function assertValidExecutionArguments(document, rawVariableValues) {
|
|
77
73
|
(0, import_devAssert.devAssert)(document, "Must provide document.");
|
|
@@ -80,7 +76,7 @@ function assertValidExecutionArguments(document, rawVariableValues) {
|
|
|
80
76
|
function buildExecutionContext(resolvers, document, rootValue, contextValue, rawVariableValues, operationName, fieldResolver, typeResolver) {
|
|
81
77
|
var _a, _b;
|
|
82
78
|
let operation;
|
|
83
|
-
const fragments = Object.create(null);
|
|
79
|
+
const fragments = /* @__PURE__ */ Object.create(null);
|
|
84
80
|
for (const definition of document.definitions) {
|
|
85
81
|
switch (definition.kind) {
|
|
86
82
|
case import_graphql.Kind.OPERATION_DEFINITION:
|
|
@@ -107,7 +103,7 @@ function buildExecutionContext(resolvers, document, rootValue, contextValue, raw
|
|
|
107
103
|
return [new import_graphql.GraphQLError("Must provide an operation.")];
|
|
108
104
|
}
|
|
109
105
|
const variableDefinitions = (_b = operation.variableDefinitions) != null ? _b : [];
|
|
110
|
-
const coercedVariableValues = (0, import_values.getVariableValues)(resolvers, variableDefinitions, rawVariableValues != null ? rawVariableValues : {}, {maxErrors: 50});
|
|
106
|
+
const coercedVariableValues = (0, import_values.getVariableValues)(resolvers, variableDefinitions, rawVariableValues != null ? rawVariableValues : {}, { maxErrors: 50 });
|
|
111
107
|
if (coercedVariableValues.errors) {
|
|
112
108
|
return coercedVariableValues.errors;
|
|
113
109
|
}
|
|
@@ -125,7 +121,7 @@ function buildExecutionContext(resolvers, document, rootValue, contextValue, raw
|
|
|
125
121
|
}
|
|
126
122
|
function executeOperation(exeContext, operation, rootValue) {
|
|
127
123
|
const typeName = getOperationRootTypeName(operation);
|
|
128
|
-
const fields = (0, import_collectFields.collectFields)(exeContext.resolvers, exeContext.fragments, exeContext.variableValues, typeName, operation.selectionSet, new Map(), new Set());
|
|
124
|
+
const fields = (0, import_collectFields.collectFields)(exeContext.resolvers, exeContext.fragments, exeContext.variableValues, typeName, operation.selectionSet, /* @__PURE__ */ new Map(), /* @__PURE__ */ new Set());
|
|
129
125
|
const path = void 0;
|
|
130
126
|
try {
|
|
131
127
|
const result = operation.operation === "mutation" ? executeFieldsSerially(exeContext, typeName, rootValue, path, fields) : executeFields(exeContext, typeName, rootValue, path, fields);
|
|
@@ -156,10 +152,10 @@ function executeFieldsSerially(exeContext, parentTypeName, sourceValue, path, fi
|
|
|
156
152
|
}
|
|
157
153
|
results[responseName] = result;
|
|
158
154
|
return results;
|
|
159
|
-
}, Object.create(null));
|
|
155
|
+
}, /* @__PURE__ */ Object.create(null));
|
|
160
156
|
}
|
|
161
157
|
function executeFields(exeContext, parentTypeName, sourceValue, path, fields) {
|
|
162
|
-
const results = Object.create(null);
|
|
158
|
+
const results = /* @__PURE__ */ Object.create(null);
|
|
163
159
|
let containsPromise = false;
|
|
164
160
|
for (const [responseName, fieldNodes] of fields.entries()) {
|
|
165
161
|
const fieldPath = (0, import_Path.addPath)(path, responseName, parentTypeName);
|
|
@@ -364,8 +360,8 @@ function invalidReturnTypeError(returnType, result, fieldNodes) {
|
|
|
364
360
|
return new import_graphql.GraphQLError(`Expected value of type "${returnType.name}" but got: ${(0, import_inspect.inspect)(result)}.`, fieldNodes);
|
|
365
361
|
}
|
|
366
362
|
function collectSubfields(exeContext, returnTypeName, fieldNodes) {
|
|
367
|
-
let subFieldNodes = new Map();
|
|
368
|
-
const visitedFragmentNames = new Set();
|
|
363
|
+
let subFieldNodes = /* @__PURE__ */ new Map();
|
|
364
|
+
const visitedFragmentNames = /* @__PURE__ */ new Set();
|
|
369
365
|
for (const node of fieldNodes) {
|
|
370
366
|
if (node.selectionSet) {
|
|
371
367
|
subFieldNodes = (0, import_collectFields.collectFields)(exeContext.resolvers, exeContext.fragments, exeContext.variableValues, returnTypeName, node.selectionSet, subFieldNodes, visitedFragmentNames);
|