@graphitation/supermassive 0.1.2 → 0.4.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.json +76 -1
- package/CHANGELOG.md +34 -2
- package/README.md +264 -2
- package/bin/supermassive.js +7 -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 +12 -6
- package/lib/benchmarks/index.d.ts.map +1 -1
- package/lib/benchmarks/index.js +127 -0
- package/lib/benchmarks/index.mjs +111 -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 +52 -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 +17 -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 +7 -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 +230 -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 +62 -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 +61 -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/executeWithSchema.d.ts +4 -0
- package/lib/executeWithSchema.d.ts.map +1 -0
- package/lib/{index.test.js → executeWithSchema.js} +45 -46
- package/lib/executeWithSchema.mjs +64 -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 +363 -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 +91 -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 +149 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +12 -29
- package/lib/index.mjs +13 -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 +17 -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 +10 -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 +24 -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 +7 -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 +83 -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 +33 -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 +10 -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 +7 -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 +7 -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 +7 -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 +7 -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 +11 -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 +11 -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 +11 -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 +28 -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 +47 -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 +7 -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 +13 -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 +12 -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 +87 -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 +14 -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 +17 -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 +160 -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 +12 -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 +138 -0
- package/package.json +21 -6
- 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
|
@@ -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,61 @@
|
|
|
1
|
+
// src/collectFields.ts
|
|
2
|
+
import {Kind} from "graphql";
|
|
3
|
+
function collectFields(resolvers, fragments, variableValues, runtimeTypeName, selectionSet, fields, visitedFragmentNames) {
|
|
4
|
+
for (const selection of selectionSet.selections) {
|
|
5
|
+
switch (selection.kind) {
|
|
6
|
+
case Kind.FIELD: {
|
|
7
|
+
if (!shouldIncludeNode(variableValues, selection)) {
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
const name = getFieldEntryKey(selection);
|
|
11
|
+
const fieldList = fields.get(name);
|
|
12
|
+
if (fieldList !== void 0) {
|
|
13
|
+
fieldList.push(selection);
|
|
14
|
+
} else {
|
|
15
|
+
fields.set(name, [selection]);
|
|
16
|
+
}
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
case Kind.INLINE_FRAGMENT: {
|
|
20
|
+
if (!shouldIncludeNode(variableValues, selection) || !doesFragmentConditionMatch(selection, runtimeTypeName)) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
collectFields(resolvers, fragments, variableValues, runtimeTypeName, selection.selectionSet, fields, visitedFragmentNames);
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
case Kind.FRAGMENT_SPREAD: {
|
|
27
|
+
const fragName = selection.name.value;
|
|
28
|
+
if (visitedFragmentNames.has(fragName) || !shouldIncludeNode(variableValues, selection)) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
visitedFragmentNames.add(fragName);
|
|
32
|
+
const fragment = fragments[fragName];
|
|
33
|
+
if (!fragment || !doesFragmentConditionMatch(fragment, runtimeTypeName)) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
collectFields(resolvers, fragments, variableValues, runtimeTypeName, fragment.selectionSet, fields, visitedFragmentNames);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return fields;
|
|
42
|
+
}
|
|
43
|
+
function shouldIncludeNode(variableValues, node) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
function doesFragmentConditionMatch(fragment, typeName) {
|
|
47
|
+
const typeConditionNode = fragment.typeCondition;
|
|
48
|
+
if (!typeConditionNode) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
if (typeConditionNode.name.value === typeName) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
function getFieldEntryKey(node) {
|
|
57
|
+
return node.alias ? node.alias.value : node.name.value;
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
collectFields
|
|
61
|
+
};
|
|
@@ -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
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PromiseOrValue } from "./jsutils/PromiseOrValue";
|
|
2
|
+
import { ExecutionResult, ExecutionWithSchemaArgs } from "./types";
|
|
3
|
+
export declare function executeWithSchema({ typeDefs, resolvers, document: rawDocument, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver, }: ExecutionWithSchemaArgs): PromiseOrValue<ExecutionResult>;
|
|
4
|
+
//# sourceMappingURL=executeWithSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executeWithSchema.d.ts","sourceRoot":"","sources":["../src/executeWithSchema.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAa,eAAe,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAE9E,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,SAAS,EACT,QAAQ,EAAE,WAAW,EACrB,SAAS,EACT,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,EACb,YAAY,GACb,EAAE,uBAAuB,GAAG,cAAc,CAAC,eAAe,CAAC,CA2B3D"}
|
|
@@ -19,6 +19,10 @@ var __objSpread = (a, b) => {
|
|
|
19
19
|
return a;
|
|
20
20
|
};
|
|
21
21
|
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
22
|
+
var __export = (target, all) => {
|
|
23
|
+
for (var name in all)
|
|
24
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
25
|
+
};
|
|
22
26
|
var __reExport = (target, module2, desc) => {
|
|
23
27
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
24
28
|
for (let key of __getOwnPropNames(module2))
|
|
@@ -30,50 +34,45 @@ var __reExport = (target, module2, desc) => {
|
|
|
30
34
|
var __toModule = (module2) => {
|
|
31
35
|
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);
|
|
32
36
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
try {
|
|
37
|
-
step(generator.next(value));
|
|
38
|
-
} catch (e) {
|
|
39
|
-
reject(e);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
var rejected = (value) => {
|
|
43
|
-
try {
|
|
44
|
-
step(generator.throw(value));
|
|
45
|
-
} catch (e) {
|
|
46
|
-
reject(e);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
50
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
var import_graphql = __toModule(require("graphql"));
|
|
54
|
-
var import__ = __toModule(require("."));
|
|
55
|
-
var import_swapi_schema = __toModule(require("../benchmarks/swapi-schema"));
|
|
56
|
-
var import_models = __toModule(require("../benchmarks/swapi-schema/models"));
|
|
57
|
-
var import_resolvers = __toModule(require("../benchmarks/swapi-schema/resolvers"));
|
|
58
|
-
describe("execute", () => {
|
|
59
|
-
it.skip("executes a basic query", () => __async(void 0, null, function* () {
|
|
60
|
-
const query = `
|
|
61
|
-
{
|
|
62
|
-
person(id: 1) {
|
|
63
|
-
name
|
|
64
|
-
gender
|
|
65
|
-
}
|
|
66
|
-
}`;
|
|
67
|
-
const document = (0, import_graphql.parse)(query);
|
|
68
|
-
expect.assertions(1);
|
|
69
|
-
const args = {
|
|
70
|
-
document,
|
|
71
|
-
contextValue: {
|
|
72
|
-
models: import_models.default
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
const result = yield (0, import__.execute)(__objSpread(__objSpread({}, args), {resolvers: import_resolvers.default}));
|
|
76
|
-
const validResult = yield (0, import_graphql.execute)(__objSpread(__objSpread({}, args), {schema: import_swapi_schema.default}));
|
|
77
|
-
expect(result).toEqual(validResult);
|
|
78
|
-
}));
|
|
37
|
+
__markAsModule(exports);
|
|
38
|
+
__export(exports, {
|
|
39
|
+
executeWithSchema: () => executeWithSchema
|
|
79
40
|
});
|
|
41
|
+
var import_schema = __toModule(require("@graphql-tools/schema"));
|
|
42
|
+
var import_graphql = __toModule(require("graphql"));
|
|
43
|
+
var import_index = __toModule(require("./index"));
|
|
44
|
+
function executeWithSchema({
|
|
45
|
+
typeDefs,
|
|
46
|
+
resolvers,
|
|
47
|
+
document: rawDocument,
|
|
48
|
+
rootValue,
|
|
49
|
+
contextValue,
|
|
50
|
+
variableValues,
|
|
51
|
+
operationName,
|
|
52
|
+
fieldResolver,
|
|
53
|
+
typeResolver
|
|
54
|
+
}) {
|
|
55
|
+
const schema = (0, import_schema.makeExecutableSchema)({typeDefs, resolvers});
|
|
56
|
+
let extractedResolvers = {};
|
|
57
|
+
const getTypeByName = (name) => {
|
|
58
|
+
const type = import_index.specifiedScalars[name] || extractedResolvers[name];
|
|
59
|
+
if ((0, import_graphql.isInputType)(type)) {
|
|
60
|
+
return type;
|
|
61
|
+
} else {
|
|
62
|
+
throw new Error("Invalid type");
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
extractedResolvers = (0, import_index.extractImplicitTypes)(typeDefs, getTypeByName);
|
|
66
|
+
const fullResolvers = __objSpread(__objSpread({}, extractedResolvers), resolvers);
|
|
67
|
+
const document = (0, import_index.addTypesToRequestDocument)(schema, rawDocument);
|
|
68
|
+
return (0, import_index.executeWithoutSchema)({
|
|
69
|
+
document,
|
|
70
|
+
resolvers: fullResolvers,
|
|
71
|
+
rootValue,
|
|
72
|
+
contextValue,
|
|
73
|
+
variableValues,
|
|
74
|
+
operationName,
|
|
75
|
+
fieldResolver,
|
|
76
|
+
typeResolver
|
|
77
|
+
});
|
|
78
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
6
|
+
var __objSpread = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/executeWithSchema.ts
|
|
19
|
+
import {makeExecutableSchema} from "@graphql-tools/schema";
|
|
20
|
+
import {isInputType} from "graphql";
|
|
21
|
+
import {
|
|
22
|
+
addTypesToRequestDocument,
|
|
23
|
+
executeWithoutSchema,
|
|
24
|
+
extractImplicitTypes,
|
|
25
|
+
specifiedScalars
|
|
26
|
+
} from "./index.mjs";
|
|
27
|
+
function executeWithSchema({
|
|
28
|
+
typeDefs,
|
|
29
|
+
resolvers,
|
|
30
|
+
document: rawDocument,
|
|
31
|
+
rootValue,
|
|
32
|
+
contextValue,
|
|
33
|
+
variableValues,
|
|
34
|
+
operationName,
|
|
35
|
+
fieldResolver,
|
|
36
|
+
typeResolver
|
|
37
|
+
}) {
|
|
38
|
+
const schema = makeExecutableSchema({typeDefs, resolvers});
|
|
39
|
+
let extractedResolvers = {};
|
|
40
|
+
const getTypeByName = (name) => {
|
|
41
|
+
const type = specifiedScalars[name] || extractedResolvers[name];
|
|
42
|
+
if (isInputType(type)) {
|
|
43
|
+
return type;
|
|
44
|
+
} else {
|
|
45
|
+
throw new Error("Invalid type");
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
extractedResolvers = extractImplicitTypes(typeDefs, getTypeByName);
|
|
49
|
+
const fullResolvers = __objSpread(__objSpread({}, extractedResolvers), resolvers);
|
|
50
|
+
const document = addTypesToRequestDocument(schema, rawDocument);
|
|
51
|
+
return executeWithoutSchema({
|
|
52
|
+
document,
|
|
53
|
+
resolvers: fullResolvers,
|
|
54
|
+
rootValue,
|
|
55
|
+
contextValue,
|
|
56
|
+
variableValues,
|
|
57
|
+
operationName,
|
|
58
|
+
fieldResolver,
|
|
59
|
+
typeResolver
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
executeWithSchema
|
|
64
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { GraphQLError } 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 { ExecutionWithoutSchemaArgs, FieldResolver, ResolveInfo, Resolvers, TypeResolver, ExecutionResult } 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
|
+
* Implements the "Executing requests" section of the GraphQL specification.
|
|
48
|
+
*
|
|
49
|
+
* Returns either a synchronous ExecutionResult (if all encountered resolvers
|
|
50
|
+
* are synchronous), or a Promise of an ExecutionResult that will eventually be
|
|
51
|
+
* resolved and never rejected.
|
|
52
|
+
*
|
|
53
|
+
* If the arguments to this function do not result in a legal execution context,
|
|
54
|
+
* a GraphQLError will be thrown immediately explaining the invalid input.
|
|
55
|
+
*/
|
|
56
|
+
export declare function executeWithoutSchema(args: ExecutionWithoutSchemaArgs): PromiseOrValue<ExecutionResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Essential assertions before executing to provide developer feedback for
|
|
59
|
+
* improper use of the GraphQL library.
|
|
60
|
+
*
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export declare function assertValidExecutionArguments(document: DocumentNode, rawVariableValues: Maybe<{
|
|
64
|
+
[variable: string]: unknown;
|
|
65
|
+
}>): void;
|
|
66
|
+
/**
|
|
67
|
+
* Constructs a ExecutionContext object from the arguments passed to
|
|
68
|
+
* execute, which we will pass throughout the other execution methods.
|
|
69
|
+
*
|
|
70
|
+
* Throws a GraphQLError if a valid execution context cannot be created.
|
|
71
|
+
*
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
export declare function buildExecutionContext(resolvers: Resolvers, document: DocumentNode, rootValue: unknown, contextValue: unknown, rawVariableValues: Maybe<{
|
|
75
|
+
[variable: string]: unknown;
|
|
76
|
+
}>, operationName: Maybe<string>, fieldResolver: Maybe<FieldResolver<unknown, unknown>>, typeResolver?: Maybe<TypeResolver<unknown, unknown>>): Array<GraphQLError> | ExecutionContext;
|
|
77
|
+
/**
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
export declare function buildResolveInfo(exeContext: ExecutionContext, fieldName: string, fieldNodes: Array<FieldNode>, parentTypeName: string, returnTypeName: string, returnTypeNode: TypeNode, path: Path): ResolveInfo;
|
|
81
|
+
/**
|
|
82
|
+
* If a resolveType function is not given, then a default resolve behavior is
|
|
83
|
+
* used which attempts two strategies:
|
|
84
|
+
*
|
|
85
|
+
* First, See if the provided value has a `__typename` field defined, if so, use
|
|
86
|
+
* that value as name of the resolved type.
|
|
87
|
+
*
|
|
88
|
+
* Otherwise, test each possible type for the abstract type by calling
|
|
89
|
+
* isTypeOf for the object being coerced, returning the first type that matches.
|
|
90
|
+
*/
|
|
91
|
+
export declare const defaultTypeResolver: TypeResolver<unknown, unknown>;
|
|
92
|
+
/**
|
|
93
|
+
* If a resolve function is not given, then a default resolve behavior is used
|
|
94
|
+
* which takes the property of the source object of the same name as the field
|
|
95
|
+
* and returns it as the result, or if it's a function, returns the result
|
|
96
|
+
* of calling that function while passing along args and context value.
|
|
97
|
+
*/
|
|
98
|
+
export declare const defaultFieldResolver: FieldResolver<unknown, unknown>;
|
|
99
|
+
//# sourceMappingURL=executeWithoutSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executeWithoutSchema.d.ts","sourceRoot":"","sources":["../src/executeWithoutSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EASb,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;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EACL,0BAA0B,EAC1B,aAAa,EAGb,WAAW,EAEX,SAAS,EACT,YAAY,EAEZ,eAAe,EAChB,MAAM,SAAS,CAAC;AAQjB;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC,sBAAsB,CAAC,CAAC;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,EAAE,uBAAuB,CAAC;IACnC,cAAc,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAChD,aAAa,EAAE,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACvC,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACrC,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;CAC7B;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,0BAA0B,GAC/B,cAAc,CAAC,eAAe,CAAC,CA0CjC;AAoBD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,YAAY,EACtB,iBAAiB,EAAE,KAAK,CAAC;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC,GACxD,IAAI,CAQN;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,OAAO,EAClB,YAAY,EAAE,OAAO,EACrB,iBAAiB,EAAE,KAAK,CAAC;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC,EACzD,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,EAC5B,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,EACrD,YAAY,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,GACnD,KAAK,CAAC,YAAY,CAAC,GAAG,gBAAgB,CAyDxC;AAgPD;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,gBAAgB,EAC5B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,EAC5B,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,QAAQ,EACxB,IAAI,EAAE,IAAI,GACT,WAAW,CAeb;AAoWD;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,CAM9D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,OAAO,EAAE,OAAO,CAchE,CAAC"}
|