@graphitation/supermassive 0.1.3 → 0.2.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/README.md +88 -0
- package/bin/supermassive.js +5 -0
- package/graphitation-supermassive-0.1.3-1.tgz +0 -0
- package/graphitation-supermassive-0.1.3-2.tgz +0 -0
- package/graphitation-supermassive-0.1.3.tgz +0 -0
- package/lib/{src/ast → ast}/TypedAST.d.ts +2 -0
- package/lib/ast/TypedAST.d.ts.map +1 -0
- package/lib/{src/ast → ast}/addTypesToRequestDocument.d.ts +0 -0
- package/lib/ast/addTypesToRequestDocument.d.ts.map +1 -0
- package/lib/ast/addTypesToRequestDocument.js +8 -5
- package/lib/ast/addTypesToRequestDocument.mjs +9 -5
- package/lib/benchmarks/index.d.ts.map +1 -1
- package/lib/benchmarks/index.js +127 -0
- package/lib/benchmarks/index.mjs +109 -0
- package/lib/benchmarks/nice-benchmark.d.ts +1 -1
- package/lib/benchmarks/nice-benchmark.d.ts.map +1 -1
- package/lib/benchmarks/nice-benchmark.js +72 -0
- package/lib/benchmarks/nice-benchmark.mjs +49 -0
- package/lib/benchmarks/swapi-schema/index.d.ts +1 -0
- package/lib/benchmarks/swapi-schema/index.d.ts.map +1 -1
- package/lib/benchmarks/swapi-schema/index.js +39 -0
- package/lib/benchmarks/swapi-schema/index.mjs +16 -0
- package/lib/benchmarks/swapi-schema/models.d.ts.map +1 -1
- package/lib/benchmarks/swapi-schema/models.js +29 -0
- package/lib/benchmarks/swapi-schema/models.mjs +6 -0
- package/lib/benchmarks/swapi-schema/resolvers.d.ts.map +1 -1
- package/lib/benchmarks/swapi-schema/resolvers.js +237 -0
- package/lib/benchmarks/swapi-schema/resolvers.mjs +231 -0
- package/lib/bin/supermassive.d.ts +3 -0
- package/lib/bin/supermassive.d.ts.map +1 -0
- package/lib/bin/supermassive.js +83 -0
- package/lib/bin/supermassive.mjs +60 -0
- package/lib/bin/typeDefsToImplicitResolvers.d.ts +3 -0
- package/lib/bin/typeDefsToImplicitResolvers.d.ts.map +1 -0
- package/lib/bin/typeDefsToImplicitResolvers.js +82 -0
- package/lib/bin/typeDefsToImplicitResolvers.mjs +59 -0
- package/lib/collectFields.d.ts +17 -0
- package/lib/collectFields.d.ts.map +1 -0
- package/lib/collectFields.js +83 -0
- package/lib/collectFields.mjs +60 -0
- package/lib/compiledQuery.d.ts +1 -0
- package/lib/compiledQuery.d.ts.map +1 -0
- package/lib/compiledQuery.js +0 -0
- package/lib/compiledQuery.mjs +0 -0
- package/lib/execute.d.ts +128 -0
- package/lib/execute.d.ts.map +1 -0
- package/lib/execute.js +376 -0
- package/lib/execute.mjs +365 -0
- package/lib/executeWithSchema.d.ts +4 -0
- package/lib/executeWithSchema.d.ts.map +1 -0
- package/lib/{index.test.js → executeWithSchema.js} +44 -45
- package/lib/executeWithSchema.mjs +62 -0
- package/lib/executeWithoutSchema.d.ts +99 -0
- package/lib/executeWithoutSchema.d.ts.map +1 -0
- package/lib/executeWithoutSchema.js +376 -0
- package/lib/executeWithoutSchema.mjs +365 -0
- package/lib/extractImplicitTypes.d.ts +6 -0
- package/lib/extractImplicitTypes.d.ts.map +1 -0
- package/lib/extractImplicitTypes.js +246 -0
- package/lib/extractImplicitTypes.mjs +233 -0
- package/lib/extractImplicitTypesRuntime.d.ts +4 -0
- package/lib/extractImplicitTypesRuntime.d.ts.map +1 -0
- package/lib/extractImplicitTypesRuntime.js +103 -0
- package/lib/extractImplicitTypesRuntime.mjs +90 -0
- package/lib/extractImplicitTypesToTypescript.d.ts +4 -0
- package/lib/extractImplicitTypesToTypescript.d.ts.map +1 -0
- package/lib/extractImplicitTypesToTypescript.js +169 -0
- package/lib/extractImplicitTypesToTypescript.mjs +148 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +14 -29
- package/lib/index.mjs +14 -29
- package/lib/jsutils/Maybe.d.ts +3 -0
- package/lib/jsutils/Maybe.d.ts.map +1 -0
- package/lib/jsutils/Maybe.js +3 -0
- package/lib/jsutils/Maybe.mjs +0 -0
- package/lib/jsutils/ObjMap.d.ts +13 -0
- package/lib/jsutils/ObjMap.d.ts.map +1 -0
- package/lib/jsutils/ObjMap.js +3 -0
- package/lib/jsutils/ObjMap.mjs +0 -0
- package/lib/jsutils/Path.d.ts +15 -0
- package/lib/jsutils/Path.d.ts.map +1 -0
- package/lib/jsutils/Path.js +23 -0
- package/lib/jsutils/Path.mjs +16 -0
- package/lib/jsutils/PromiseOrValue.d.ts +2 -0
- package/lib/jsutils/PromiseOrValue.d.ts.map +1 -0
- package/lib/jsutils/PromiseOrValue.js +3 -0
- package/lib/jsutils/PromiseOrValue.mjs +0 -0
- package/lib/jsutils/devAssert.d.ts +2 -0
- package/lib/jsutils/devAssert.d.ts.map +1 -0
- package/lib/jsutils/devAssert.js +16 -0
- package/lib/jsutils/devAssert.mjs +9 -0
- package/lib/jsutils/didYouMean.d.ts +6 -0
- package/lib/jsutils/didYouMean.d.ts.map +1 -0
- package/lib/jsutils/didYouMean.js +30 -0
- package/lib/jsutils/didYouMean.mjs +23 -0
- package/lib/jsutils/identityFunc.d.ts +5 -0
- package/lib/jsutils/identityFunc.d.ts.map +1 -0
- package/lib/jsutils/identityFunc.js +13 -0
- package/lib/jsutils/identityFunc.mjs +6 -0
- package/lib/jsutils/inspect.d.ts +5 -0
- package/lib/jsutils/inspect.d.ts.map +1 -0
- package/lib/jsutils/inspect.js +89 -0
- package/lib/jsutils/inspect.mjs +82 -0
- package/lib/jsutils/instanceOf.d.ts +14 -0
- package/lib/jsutils/instanceOf.d.ts.map +1 -0
- package/lib/jsutils/instanceOf.js +55 -0
- package/lib/jsutils/instanceOf.mjs +32 -0
- package/lib/jsutils/invariant.d.ts +2 -0
- package/lib/jsutils/invariant.d.ts.map +1 -0
- package/lib/jsutils/invariant.js +16 -0
- package/lib/jsutils/invariant.mjs +9 -0
- package/lib/jsutils/isAsyncIterable.d.ts +6 -0
- package/lib/jsutils/isAsyncIterable.d.ts.map +1 -0
- package/lib/jsutils/isAsyncIterable.js +13 -0
- package/lib/jsutils/isAsyncIterable.mjs +6 -0
- package/lib/jsutils/isIterableObject.d.ts +18 -0
- package/lib/jsutils/isIterableObject.d.ts.map +1 -0
- package/lib/jsutils/isIterableObject.js +13 -0
- package/lib/jsutils/isIterableObject.mjs +6 -0
- package/lib/jsutils/isObjectLike.d.ts +8 -0
- package/lib/jsutils/isObjectLike.d.ts.map +1 -0
- package/lib/jsutils/isObjectLike.js +13 -0
- package/lib/jsutils/isObjectLike.mjs +6 -0
- package/lib/jsutils/isPromise.d.ts +6 -0
- package/lib/jsutils/isPromise.d.ts.map +1 -0
- package/lib/jsutils/isPromise.js +13 -0
- package/lib/jsutils/isPromise.mjs +6 -0
- package/lib/jsutils/keyMap.d.ts +26 -0
- package/lib/jsutils/keyMap.d.ts.map +1 -0
- package/lib/jsutils/keyMap.js +17 -0
- package/lib/jsutils/keyMap.mjs +10 -0
- package/lib/jsutils/keyValMap.d.ts +20 -0
- package/lib/jsutils/keyValMap.d.ts.map +1 -0
- package/lib/jsutils/keyValMap.js +17 -0
- package/lib/jsutils/keyValMap.mjs +10 -0
- package/lib/jsutils/mapValue.d.ts +7 -0
- package/lib/jsutils/mapValue.d.ts.map +1 -0
- package/lib/jsutils/mapValue.js +17 -0
- package/lib/jsutils/mapValue.mjs +10 -0
- package/lib/jsutils/memoize3.d.ts +5 -0
- package/lib/jsutils/memoize3.d.ts.map +1 -0
- package/lib/jsutils/memoize3.js +34 -0
- package/lib/jsutils/memoize3.mjs +27 -0
- package/lib/jsutils/naturalCompare.d.ts +9 -0
- package/lib/jsutils/naturalCompare.d.ts.map +1 -0
- package/lib/jsutils/naturalCompare.js +53 -0
- package/lib/jsutils/naturalCompare.mjs +46 -0
- package/lib/jsutils/printPathArray.d.ts +5 -0
- package/lib/jsutils/printPathArray.d.ts.map +1 -0
- package/lib/jsutils/printPathArray.js +13 -0
- package/lib/jsutils/printPathArray.mjs +6 -0
- package/lib/jsutils/promiseForObject.d.ts +10 -0
- package/lib/jsutils/promiseForObject.d.ts.map +1 -0
- package/lib/jsutils/promiseForObject.js +19 -0
- package/lib/jsutils/promiseForObject.mjs +12 -0
- package/lib/jsutils/promiseReduce.d.ts +10 -0
- package/lib/jsutils/promiseReduce.d.ts.map +1 -0
- package/lib/jsutils/promiseReduce.js +34 -0
- package/lib/jsutils/promiseReduce.mjs +11 -0
- package/lib/jsutils/suggestionList.d.ts +6 -0
- package/lib/jsutils/suggestionList.d.ts.map +1 -0
- package/lib/jsutils/suggestionList.js +109 -0
- package/lib/jsutils/suggestionList.mjs +86 -0
- package/lib/jsutils/toObjMap.d.ts +4 -0
- package/lib/jsutils/toObjMap.d.ts.map +1 -0
- package/lib/jsutils/toObjMap.js +20 -0
- package/lib/jsutils/toObjMap.mjs +13 -0
- package/lib/transforms/annotateDocumentGraphQLTransform.d.ts +3 -0
- package/lib/transforms/annotateDocumentGraphQLTransform.d.ts.map +1 -0
- package/lib/transforms/annotateDocumentGraphQLTransform.js +37 -0
- package/lib/transforms/annotateDocumentGraphQLTransform.mjs +16 -0
- package/lib/transforms/transformerTestUtils.d.ts +79 -0
- package/lib/transforms/transformerTestUtils.d.ts.map +1 -0
- package/lib/transforms/transformerTestUtils.js +175 -0
- package/lib/transforms/transformerTestUtils.mjs +154 -0
- package/lib/types.d.ts +74 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +3 -0
- package/lib/types.mjs +0 -0
- package/lib/utilities/typeNameFromAST.d.ts +3 -0
- package/lib/utilities/typeNameFromAST.d.ts.map +1 -0
- package/lib/utilities/typeNameFromAST.js +34 -0
- package/lib/utilities/typeNameFromAST.mjs +11 -0
- package/lib/values.d.ts +64 -0
- package/lib/values.d.ts.map +1 -0
- package/lib/values.js +145 -0
- package/lib/values.mjs +137 -0
- package/package.json +9 -4
- package/CHANGELOG.json +0 -65
- package/benchmarks/fixtures/query1.graphql +0 -20
- package/benchmarks/index.ts +0 -68
- package/benchmarks/nice-benchmark.ts +0 -32
- package/benchmarks/swapi-schema/index.ts +0 -13
- package/benchmarks/swapi-schema/models.ts +0 -4
- package/benchmarks/swapi-schema/resolvers.ts +0 -331
- package/benchmarks/swapi-schema/schema.graphql +0 -164
- package/benchmarks/swapi-schema/starwars.json +0 -5991
- package/lib/index.test.mjs +0 -63
- package/lib/src/ast/TypedAST.d.ts.map +0 -1
- package/lib/src/ast/addTypesToRequestDocument.d.ts.map +0 -1
- package/lib/src/index.d.ts +0 -16
- package/lib/src/index.d.ts.map +0 -1
- package/lib/src/index.test.d.ts +0 -2
- package/lib/src/index.test.d.ts.map +0 -1
- package/starwars.json +0 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
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
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
+
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
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);
|
|
22
|
+
};
|
|
23
|
+
var __async = (__this, __arguments, generator) => {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
var fulfilled = (value) => {
|
|
26
|
+
try {
|
|
27
|
+
step(generator.next(value));
|
|
28
|
+
} catch (e) {
|
|
29
|
+
reject(e);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var rejected = (value) => {
|
|
33
|
+
try {
|
|
34
|
+
step(generator.throw(value));
|
|
35
|
+
} catch (e) {
|
|
36
|
+
reject(e);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
40
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
__markAsModule(exports);
|
|
44
|
+
__export(exports, {
|
|
45
|
+
supermassive: () => supermassive
|
|
46
|
+
});
|
|
47
|
+
var import_path = __toModule(require("path"));
|
|
48
|
+
var import_promises = __toModule(require("fs/promises"));
|
|
49
|
+
var import_typescript = __toModule(require("typescript"));
|
|
50
|
+
var import_commander = __toModule(require("commander"));
|
|
51
|
+
var import_extractImplicitTypesToTypescript = __toModule(require("../extractImplicitTypesToTypescript"));
|
|
52
|
+
var import_graphql = __toModule(require("graphql"));
|
|
53
|
+
function supermassive() {
|
|
54
|
+
const command = new import_commander.Command();
|
|
55
|
+
command.name("extract-schema").argument("<files...>").description("extract implicit resolvers to a ts file from graphql typedefs").action((files) => __async(this, null, function* () {
|
|
56
|
+
yield typeDefsToImplicitResolversImpl(files);
|
|
57
|
+
}));
|
|
58
|
+
return import_commander.program.name("supermassive").addCommand(command);
|
|
59
|
+
}
|
|
60
|
+
function typeDefsToImplicitResolversImpl(files) {
|
|
61
|
+
return __async(this, null, function* () {
|
|
62
|
+
for (const file of files) {
|
|
63
|
+
let fullPath;
|
|
64
|
+
if (import_path.default.isAbsolute(file)) {
|
|
65
|
+
fullPath = file;
|
|
66
|
+
} else {
|
|
67
|
+
fullPath = import_path.default.join(process.cwd(), file);
|
|
68
|
+
}
|
|
69
|
+
const stat = yield import_promises.default.stat(fullPath);
|
|
70
|
+
if (!stat.isFile) {
|
|
71
|
+
throw new Error(`Invalid file ${file}`);
|
|
72
|
+
}
|
|
73
|
+
const content = yield import_promises.default.readFile(fullPath, {encoding: "utf-8"});
|
|
74
|
+
const document = (0, import_graphql.parse)(content);
|
|
75
|
+
const tsContents = (0, import_extractImplicitTypesToTypescript.extractImplicitTypesToTypescript)(document);
|
|
76
|
+
const tsDir = import_path.default.join(import_path.default.dirname(fullPath), "__generated__");
|
|
77
|
+
yield import_promises.default.mkdir(tsDir, {recursive: true});
|
|
78
|
+
const tsFileName = import_path.default.join(tsDir, import_path.default.basename(fullPath, import_path.default.extname(fullPath)) + ".ts");
|
|
79
|
+
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"});
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import path from "path";
|
|
22
|
+
import fs from "fs/promises";
|
|
23
|
+
import ts from "typescript";
|
|
24
|
+
import {program, Command} from "commander";
|
|
25
|
+
import {extractImplicitTypesToTypescript} from "../extractImplicitTypesToTypescript";
|
|
26
|
+
import {parse} from "graphql";
|
|
27
|
+
function supermassive() {
|
|
28
|
+
const command = new Command();
|
|
29
|
+
command.name("extract-schema").argument("<files...>").description("extract implicit resolvers to a ts file from graphql typedefs").action((files) => __async(this, null, function* () {
|
|
30
|
+
yield typeDefsToImplicitResolversImpl(files);
|
|
31
|
+
}));
|
|
32
|
+
return program.name("supermassive").addCommand(command);
|
|
33
|
+
}
|
|
34
|
+
function typeDefsToImplicitResolversImpl(files) {
|
|
35
|
+
return __async(this, null, function* () {
|
|
36
|
+
for (const file of files) {
|
|
37
|
+
let fullPath;
|
|
38
|
+
if (path.isAbsolute(file)) {
|
|
39
|
+
fullPath = file;
|
|
40
|
+
} else {
|
|
41
|
+
fullPath = path.join(process.cwd(), file);
|
|
42
|
+
}
|
|
43
|
+
const stat = yield fs.stat(fullPath);
|
|
44
|
+
if (!stat.isFile) {
|
|
45
|
+
throw new Error(`Invalid file ${file}`);
|
|
46
|
+
}
|
|
47
|
+
const content = yield fs.readFile(fullPath, {encoding: "utf-8"});
|
|
48
|
+
const document = parse(content);
|
|
49
|
+
const tsContents = extractImplicitTypesToTypescript(document);
|
|
50
|
+
const tsDir = path.join(path.dirname(fullPath), "__generated__");
|
|
51
|
+
yield fs.mkdir(tsDir, {recursive: true});
|
|
52
|
+
const tsFileName = path.join(tsDir, path.basename(fullPath, path.extname(fullPath)) + ".ts");
|
|
53
|
+
const printer = ts.createPrinter();
|
|
54
|
+
yield fs.writeFile(tsFileName, printer.printNode(ts.EmitHint.SourceFile, tsContents, tsContents), {encoding: "utf-8"});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
supermassive
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeDefsToImplicitResolvers.d.ts","sourceRoot":"","sources":["../../src/bin/typeDefsToImplicitResolvers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,2BAA2B,IAAI,OAAO,CAOrD"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
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
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
+
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
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);
|
|
22
|
+
};
|
|
23
|
+
var __async = (__this, __arguments, generator) => {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
var fulfilled = (value) => {
|
|
26
|
+
try {
|
|
27
|
+
step(generator.next(value));
|
|
28
|
+
} catch (e) {
|
|
29
|
+
reject(e);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var rejected = (value) => {
|
|
33
|
+
try {
|
|
34
|
+
step(generator.throw(value));
|
|
35
|
+
} catch (e) {
|
|
36
|
+
reject(e);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
40
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
__markAsModule(exports);
|
|
44
|
+
__export(exports, {
|
|
45
|
+
typeDefsToImplicitResolvers: () => typeDefsToImplicitResolvers
|
|
46
|
+
});
|
|
47
|
+
var import_path = __toModule(require("path"));
|
|
48
|
+
var import_promises = __toModule(require("fs/promises"));
|
|
49
|
+
var import_typescript = __toModule(require("typescript"));
|
|
50
|
+
var import_commander = __toModule(require("commander"));
|
|
51
|
+
var import_extractImplicitTypes = __toModule(require("../extractImplicitTypes"));
|
|
52
|
+
var import_graphql = __toModule(require("graphql"));
|
|
53
|
+
function typeDefsToImplicitResolvers() {
|
|
54
|
+
const program = new import_commander.Command();
|
|
55
|
+
return program.argument("<files...>", "graphql typedef files to convert").action((files) => __async(this, null, function* () {
|
|
56
|
+
yield typeDefsToImplicitResolversImpl(files);
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
function typeDefsToImplicitResolversImpl(files) {
|
|
60
|
+
return __async(this, null, function* () {
|
|
61
|
+
for (const file of files) {
|
|
62
|
+
let fullPath;
|
|
63
|
+
if (import_path.default.isAbsolute(file)) {
|
|
64
|
+
fullPath = file;
|
|
65
|
+
} else {
|
|
66
|
+
fullPath = import_path.default.join(process.cwd(), file);
|
|
67
|
+
}
|
|
68
|
+
const stat = yield import_promises.default.stat(fullPath);
|
|
69
|
+
if (!stat.isFile) {
|
|
70
|
+
throw new Error(`Invalid file ${file}`);
|
|
71
|
+
}
|
|
72
|
+
const content = yield import_promises.default.readFile(fullPath, {encoding: "utf-8"});
|
|
73
|
+
const document = (0, import_graphql.parse)(content);
|
|
74
|
+
const tsContents = (0, import_extractImplicitTypes.extractImplicitTypesToTypescript)(document);
|
|
75
|
+
const tsDir = import_path.default.join(import_path.default.dirname(fullPath), "__generated__");
|
|
76
|
+
yield import_promises.default.mkdir(tsDir, {recursive: true});
|
|
77
|
+
const tsFileName = import_path.default.join(tsDir, import_path.default.basename(fullPath, import_path.default.extname(fullPath)) + ".ts");
|
|
78
|
+
const printer = import_typescript.default.createPrinter();
|
|
79
|
+
yield import_promises.default.writeFile(tsFileName, printer.printNode(import_typescript.default.EmitHint.SourceFile, tsContents, tsContents), {encoding: "utf-8"});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import path from "path";
|
|
22
|
+
import fs from "fs/promises";
|
|
23
|
+
import ts from "typescript";
|
|
24
|
+
import {Command} from "commander";
|
|
25
|
+
import {extractImplicitTypesToTypescript} from "../extractImplicitTypes";
|
|
26
|
+
import {parse} from "graphql";
|
|
27
|
+
function typeDefsToImplicitResolvers() {
|
|
28
|
+
const program = new Command();
|
|
29
|
+
return program.argument("<files...>", "graphql typedef files to convert").action((files) => __async(this, null, function* () {
|
|
30
|
+
yield typeDefsToImplicitResolversImpl(files);
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
function typeDefsToImplicitResolversImpl(files) {
|
|
34
|
+
return __async(this, null, function* () {
|
|
35
|
+
for (const file of files) {
|
|
36
|
+
let fullPath;
|
|
37
|
+
if (path.isAbsolute(file)) {
|
|
38
|
+
fullPath = file;
|
|
39
|
+
} else {
|
|
40
|
+
fullPath = path.join(process.cwd(), file);
|
|
41
|
+
}
|
|
42
|
+
const stat = yield fs.stat(fullPath);
|
|
43
|
+
if (!stat.isFile) {
|
|
44
|
+
throw new Error(`Invalid file ${file}`);
|
|
45
|
+
}
|
|
46
|
+
const content = yield fs.readFile(fullPath, {encoding: "utf-8"});
|
|
47
|
+
const document = parse(content);
|
|
48
|
+
const tsContents = extractImplicitTypesToTypescript(document);
|
|
49
|
+
const tsDir = path.join(path.dirname(fullPath), "__generated__");
|
|
50
|
+
yield fs.mkdir(tsDir, {recursive: true});
|
|
51
|
+
const tsFileName = path.join(tsDir, path.basename(fullPath, path.extname(fullPath)) + ".ts");
|
|
52
|
+
const printer = ts.createPrinter();
|
|
53
|
+
yield fs.writeFile(tsFileName, printer.printNode(ts.EmitHint.SourceFile, tsContents, tsContents), {encoding: "utf-8"});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
typeDefsToImplicitResolvers
|
|
59
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FieldNode, FragmentDefinitionNode, SelectionSetNode } from "./ast/TypedAST";
|
|
2
|
+
import type { ObjMap } from "./jsutils/ObjMap";
|
|
3
|
+
import { Resolvers } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Given a selectionSet, adds all of the fields in that selection to
|
|
6
|
+
* the passed in map of fields, and returns it at the end.
|
|
7
|
+
*
|
|
8
|
+
* CollectFields requires the "runtime type" of an object. For a field which
|
|
9
|
+
* returns an Interface or Union type, the "runtime type" will be the actual
|
|
10
|
+
* Object type returned by that field.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare function collectFields(resolvers: Resolvers, fragments: ObjMap<FragmentDefinitionNode>, variableValues: {
|
|
15
|
+
[variable: string]: unknown;
|
|
16
|
+
}, runtimeTypeName: string, selectionSet: SelectionSetNode, fields: Map<string, Array<FieldNode>>, visitedFragmentNames: Set<string>): Map<string, Array<FieldNode>>;
|
|
17
|
+
//# sourceMappingURL=collectFields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collectFields.d.ts","sourceRoot":"","sources":["../src/collectFields.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,sBAAsB,EAGtB,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,MAAM,CAAC,sBAAsB,CAAC,EACzC,cAAc,EAAE;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAC/C,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,gBAAgB,EAC9B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,EACrC,oBAAoB,EAAE,GAAG,CAAC,MAAM,CAAC,GAChC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAgE/B"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
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
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
+
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
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);
|
|
22
|
+
};
|
|
23
|
+
__markAsModule(exports);
|
|
24
|
+
__export(exports, {
|
|
25
|
+
collectFields: () => collectFields
|
|
26
|
+
});
|
|
27
|
+
var import_graphql = __toModule(require("graphql"));
|
|
28
|
+
function collectFields(resolvers, fragments, variableValues, runtimeTypeName, selectionSet, fields, visitedFragmentNames) {
|
|
29
|
+
for (const selection of selectionSet.selections) {
|
|
30
|
+
switch (selection.kind) {
|
|
31
|
+
case import_graphql.Kind.FIELD: {
|
|
32
|
+
if (!shouldIncludeNode(variableValues, selection)) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const name = getFieldEntryKey(selection);
|
|
36
|
+
const fieldList = fields.get(name);
|
|
37
|
+
if (fieldList !== void 0) {
|
|
38
|
+
fieldList.push(selection);
|
|
39
|
+
} else {
|
|
40
|
+
fields.set(name, [selection]);
|
|
41
|
+
}
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
case import_graphql.Kind.INLINE_FRAGMENT: {
|
|
45
|
+
if (!shouldIncludeNode(variableValues, selection) || !doesFragmentConditionMatch(selection, runtimeTypeName)) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
collectFields(resolvers, fragments, variableValues, runtimeTypeName, selection.selectionSet, fields, visitedFragmentNames);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
case import_graphql.Kind.FRAGMENT_SPREAD: {
|
|
52
|
+
const fragName = selection.name.value;
|
|
53
|
+
if (visitedFragmentNames.has(fragName) || !shouldIncludeNode(variableValues, selection)) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
visitedFragmentNames.add(fragName);
|
|
57
|
+
const fragment = fragments[fragName];
|
|
58
|
+
if (!fragment || !doesFragmentConditionMatch(fragment, runtimeTypeName)) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
collectFields(resolvers, fragments, variableValues, runtimeTypeName, fragment.selectionSet, fields, visitedFragmentNames);
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return fields;
|
|
67
|
+
}
|
|
68
|
+
function shouldIncludeNode(variableValues, node) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
function doesFragmentConditionMatch(fragment, typeName) {
|
|
72
|
+
const typeConditionNode = fragment.typeCondition;
|
|
73
|
+
if (!typeConditionNode) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
if (typeConditionNode.name.value === typeName) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
function getFieldEntryKey(node) {
|
|
82
|
+
return node.alias ? node.alias.value : node.name.value;
|
|
83
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {Kind} from "graphql";
|
|
2
|
+
function collectFields(resolvers, fragments, variableValues, runtimeTypeName, selectionSet, fields, visitedFragmentNames) {
|
|
3
|
+
for (const selection of selectionSet.selections) {
|
|
4
|
+
switch (selection.kind) {
|
|
5
|
+
case Kind.FIELD: {
|
|
6
|
+
if (!shouldIncludeNode(variableValues, selection)) {
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
const name = getFieldEntryKey(selection);
|
|
10
|
+
const fieldList = fields.get(name);
|
|
11
|
+
if (fieldList !== void 0) {
|
|
12
|
+
fieldList.push(selection);
|
|
13
|
+
} else {
|
|
14
|
+
fields.set(name, [selection]);
|
|
15
|
+
}
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
case Kind.INLINE_FRAGMENT: {
|
|
19
|
+
if (!shouldIncludeNode(variableValues, selection) || !doesFragmentConditionMatch(selection, runtimeTypeName)) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
collectFields(resolvers, fragments, variableValues, runtimeTypeName, selection.selectionSet, fields, visitedFragmentNames);
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
case Kind.FRAGMENT_SPREAD: {
|
|
26
|
+
const fragName = selection.name.value;
|
|
27
|
+
if (visitedFragmentNames.has(fragName) || !shouldIncludeNode(variableValues, selection)) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
visitedFragmentNames.add(fragName);
|
|
31
|
+
const fragment = fragments[fragName];
|
|
32
|
+
if (!fragment || !doesFragmentConditionMatch(fragment, runtimeTypeName)) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
collectFields(resolvers, fragments, variableValues, runtimeTypeName, fragment.selectionSet, fields, visitedFragmentNames);
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return fields;
|
|
41
|
+
}
|
|
42
|
+
function shouldIncludeNode(variableValues, node) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
function doesFragmentConditionMatch(fragment, typeName) {
|
|
46
|
+
const typeConditionNode = fragment.typeCondition;
|
|
47
|
+
if (!typeConditionNode) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
if (typeConditionNode.name.value === typeName) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
function getFieldEntryKey(node) {
|
|
56
|
+
return node.alias ? node.alias.value : node.name.value;
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
collectFields
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=compiledQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiledQuery.d.ts","sourceRoot":"","sources":["../src/compiledQuery.ts"],"names":[],"mappings":""}
|
|
File without changes
|
|
File without changes
|
package/lib/execute.d.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { GraphQLError, GraphQLFormattedError } from "graphql";
|
|
2
|
+
import { DocumentNode, FieldNode, FragmentDefinitionNode, OperationDefinitionNode, TypeNode } from "./ast/TypedAST";
|
|
3
|
+
import type { Maybe } from "./jsutils/Maybe";
|
|
4
|
+
import type { ObjMap } from "./jsutils/ObjMap";
|
|
5
|
+
import type { Path } from "./jsutils/Path";
|
|
6
|
+
import type { PromiseOrValue } from "./jsutils/PromiseOrValue";
|
|
7
|
+
import { FieldResolver, ResolveInfo, Resolvers, TypeResolver } from "./types";
|
|
8
|
+
/**
|
|
9
|
+
* Terminology
|
|
10
|
+
*
|
|
11
|
+
* "Definitions" are the generic name for top-level statements in the document.
|
|
12
|
+
* Examples of this include:
|
|
13
|
+
* 1) Operations (such as a query)
|
|
14
|
+
* 2) Fragments
|
|
15
|
+
*
|
|
16
|
+
* "Operations" are a generic name for requests in the document.
|
|
17
|
+
* Examples of this include:
|
|
18
|
+
* 1) query,
|
|
19
|
+
* 2) mutation
|
|
20
|
+
*
|
|
21
|
+
* "Selections" are the definitions that can appear legally and at
|
|
22
|
+
* single level of the query. These include:
|
|
23
|
+
* 1) field references e.g "a"
|
|
24
|
+
* 2) fragment "spreads" e.g. "...c"
|
|
25
|
+
* 3) inline fragment "spreads" e.g. "...on Type { a }"
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Data that must be available at all points during query execution.
|
|
29
|
+
*
|
|
30
|
+
* Namely, schema of the type system that is currently executing,
|
|
31
|
+
* and the fragments defined in the query document
|
|
32
|
+
*/
|
|
33
|
+
export interface ExecutionContext {
|
|
34
|
+
resolvers: Resolvers;
|
|
35
|
+
fragments: ObjMap<FragmentDefinitionNode>;
|
|
36
|
+
rootValue: unknown;
|
|
37
|
+
contextValue: unknown;
|
|
38
|
+
operation: OperationDefinitionNode;
|
|
39
|
+
variableValues: {
|
|
40
|
+
[variable: string]: unknown;
|
|
41
|
+
};
|
|
42
|
+
fieldResolver: FieldResolver<any, any>;
|
|
43
|
+
typeResolver: TypeResolver<any, any>;
|
|
44
|
+
errors: Array<GraphQLError>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The result of GraphQL execution.
|
|
48
|
+
*
|
|
49
|
+
* - `errors` is included when any errors occurred as a non-empty array.
|
|
50
|
+
* - `data` is the result of a successful execution of the query.
|
|
51
|
+
* - `extensions` is reserved for adding non-standard properties.
|
|
52
|
+
*/
|
|
53
|
+
export interface ExecutionResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> {
|
|
54
|
+
errors?: Array<GraphQLError>;
|
|
55
|
+
data?: TData | null;
|
|
56
|
+
extensions?: TExtensions;
|
|
57
|
+
}
|
|
58
|
+
export interface FormattedExecutionResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> {
|
|
59
|
+
errors?: Array<GraphQLFormattedError>;
|
|
60
|
+
data?: TData | null;
|
|
61
|
+
extensions?: TExtensions;
|
|
62
|
+
}
|
|
63
|
+
export interface ExecutionArgs {
|
|
64
|
+
resolvers: Resolvers;
|
|
65
|
+
document: DocumentNode;
|
|
66
|
+
rootValue?: unknown;
|
|
67
|
+
contextValue?: unknown;
|
|
68
|
+
variableValues?: Maybe<{
|
|
69
|
+
[variable: string]: unknown;
|
|
70
|
+
}>;
|
|
71
|
+
operationName?: Maybe<string>;
|
|
72
|
+
fieldResolver?: Maybe<FieldResolver<any, any>>;
|
|
73
|
+
typeResolver?: Maybe<TypeResolver<any, any>>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Implements the "Executing requests" section of the GraphQL specification.
|
|
77
|
+
*
|
|
78
|
+
* Returns either a synchronous ExecutionResult (if all encountered resolvers
|
|
79
|
+
* are synchronous), or a Promise of an ExecutionResult that will eventually be
|
|
80
|
+
* resolved and never rejected.
|
|
81
|
+
*
|
|
82
|
+
* If the arguments to this function do not result in a legal execution context,
|
|
83
|
+
* a GraphQLError will be thrown immediately explaining the invalid input.
|
|
84
|
+
*/
|
|
85
|
+
export declare function execute(args: ExecutionArgs): PromiseOrValue<ExecutionResult>;
|
|
86
|
+
/**
|
|
87
|
+
* Essential assertions before executing to provide developer feedback for
|
|
88
|
+
* improper use of the GraphQL library.
|
|
89
|
+
*
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
export declare function assertValidExecutionArguments(document: DocumentNode, rawVariableValues: Maybe<{
|
|
93
|
+
[variable: string]: unknown;
|
|
94
|
+
}>): void;
|
|
95
|
+
/**
|
|
96
|
+
* Constructs a ExecutionContext object from the arguments passed to
|
|
97
|
+
* execute, which we will pass throughout the other execution methods.
|
|
98
|
+
*
|
|
99
|
+
* Throws a GraphQLError if a valid execution context cannot be created.
|
|
100
|
+
*
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
export declare function buildExecutionContext(resolvers: Resolvers, document: DocumentNode, rootValue: unknown, contextValue: unknown, rawVariableValues: Maybe<{
|
|
104
|
+
[variable: string]: unknown;
|
|
105
|
+
}>, operationName: Maybe<string>, fieldResolver: Maybe<FieldResolver<unknown, unknown>>, typeResolver?: Maybe<TypeResolver<unknown, unknown>>): Array<GraphQLError> | ExecutionContext;
|
|
106
|
+
/**
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
export declare function buildResolveInfo(exeContext: ExecutionContext, fieldName: string, fieldNodes: Array<FieldNode>, parentTypeName: string, returnTypeName: string, returnTypeNode: TypeNode, path: Path): ResolveInfo;
|
|
110
|
+
/**
|
|
111
|
+
* If a resolveType function is not given, then a default resolve behavior is
|
|
112
|
+
* used which attempts two strategies:
|
|
113
|
+
*
|
|
114
|
+
* First, See if the provided value has a `__typename` field defined, if so, use
|
|
115
|
+
* that value as name of the resolved type.
|
|
116
|
+
*
|
|
117
|
+
* Otherwise, test each possible type for the abstract type by calling
|
|
118
|
+
* isTypeOf for the object being coerced, returning the first type that matches.
|
|
119
|
+
*/
|
|
120
|
+
export declare const defaultTypeResolver: TypeResolver<unknown, unknown>;
|
|
121
|
+
/**
|
|
122
|
+
* If a resolve function is not given, then a default resolve behavior is used
|
|
123
|
+
* which takes the property of the source object of the same name as the field
|
|
124
|
+
* and returns it as the result, or if it's a function, returns the result
|
|
125
|
+
* of calling that function while passing along args and context value.
|
|
126
|
+
*/
|
|
127
|
+
export declare const defaultFieldResolver: FieldResolver<unknown, unknown>;
|
|
128
|
+
//# sourceMappingURL=execute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../src/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,qBAAqB,EAQtB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,YAAY,EACZ,SAAS,EACT,sBAAsB,EACtB,uBAAuB,EAEvB,QAAQ,EACT,MAAM,gBAAgB,CAAC;AAQxB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;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