@graphitation/supermassive 0.2.0 → 0.4.2
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 +155 -0
- package/CHANGELOG.md +34 -2
- package/NOTICE +27 -0
- package/README.md +179 -5
- package/lib/ast/addTypesToRequestDocument.mjs +3 -1
- package/lib/benchmarks/index.mjs +16 -14
- package/lib/benchmarks/nice-benchmark.mjs +6 -3
- package/lib/benchmarks/swapi-schema/index.mjs +3 -2
- package/lib/benchmarks/swapi-schema/models.mjs +1 -0
- package/lib/benchmarks/swapi-schema/resolvers.mjs +23 -24
- package/lib/bin/supermassive.d.ts.map +1 -1
- package/lib/bin/supermassive.mjs +3 -1
- package/lib/collectFields.mjs +1 -0
- package/lib/executeWithSchema.d.ts.map +1 -1
- package/lib/executeWithSchema.js +8 -8
- package/lib/executeWithSchema.mjs +6 -4
- package/lib/executeWithoutSchema.mjs +15 -17
- package/lib/extractImplicitTypesRuntime.mjs +1 -0
- package/lib/extractImplicitTypesToTypescript.mjs +2 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -2
- package/lib/index.mjs +7 -8
- package/lib/jsutils/Path.mjs +1 -0
- package/lib/jsutils/devAssert.mjs +1 -0
- package/lib/jsutils/didYouMean.mjs +2 -1
- package/lib/jsutils/identityFunc.mjs +1 -0
- package/lib/jsutils/inspect.mjs +3 -2
- package/lib/jsutils/instanceOf.mjs +3 -2
- package/lib/jsutils/invariant.mjs +1 -0
- package/lib/jsutils/isAsyncIterable.mjs +1 -0
- package/lib/jsutils/isIterableObject.mjs +1 -0
- package/lib/jsutils/isObjectLike.mjs +1 -0
- package/lib/jsutils/isPromise.mjs +1 -0
- package/lib/jsutils/keyMap.mjs +1 -0
- package/lib/jsutils/keyValMap.mjs +1 -0
- package/lib/jsutils/mapValue.mjs +1 -0
- package/lib/jsutils/memoize3.mjs +1 -0
- package/lib/jsutils/naturalCompare.mjs +3 -2
- package/lib/jsutils/printPathArray.mjs +1 -0
- package/lib/jsutils/promiseForObject.mjs +1 -0
- package/lib/jsutils/promiseReduce.mjs +2 -1
- package/lib/jsutils/suggestionList.mjs +4 -3
- package/lib/jsutils/toObjMap.mjs +1 -0
- package/lib/transforms/annotateDocumentGraphQLTransform.mjs +3 -2
- package/lib/transforms/transformerTestUtils.mjs +14 -8
- package/lib/utilities/typeNameFromAST.mjs +1 -0
- package/lib/values.mjs +5 -4
- package/package.json +13 -3
- package/starwars.json +1 -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/bin/typeDefsToImplicitResolvers.d.ts +0 -3
- package/lib/bin/typeDefsToImplicitResolvers.d.ts.map +0 -1
- package/lib/bin/typeDefsToImplicitResolvers.js +0 -82
- package/lib/bin/typeDefsToImplicitResolvers.mjs +0 -59
- package/lib/execute.d.ts +0 -128
- package/lib/execute.d.ts.map +0 -1
- package/lib/execute.js +0 -376
- package/lib/execute.mjs +0 -365
- package/lib/extractImplicitTypes.d.ts +0 -6
- package/lib/extractImplicitTypes.d.ts.map +0 -1
- package/lib/extractImplicitTypes.js +0 -246
- package/lib/extractImplicitTypes.mjs +0 -233
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
// src/benchmarks/swapi-schema/index.ts
|
|
1
2
|
import {makeExecutableSchema} from "@graphql-tools/schema";
|
|
2
3
|
import {parse} from "graphql";
|
|
3
4
|
import {join} from "path";
|
|
4
5
|
import {readFileSync} from "fs";
|
|
5
|
-
import resolvers from "./resolvers";
|
|
6
|
-
|
|
6
|
+
import resolvers from "./resolvers.mjs";
|
|
7
|
+
var typeDefs = parse(readFileSync(join(__dirname, "./schema.graphql"), {
|
|
7
8
|
encoding: "utf-8"
|
|
8
9
|
}));
|
|
9
10
|
var swapi_schema_default = makeExecutableSchema({
|
|
@@ -14,10 +14,12 @@ var __objSpread = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
// src/benchmarks/swapi-schema/resolvers.ts
|
|
19
|
+
var films = (parent, args, {models}) => {
|
|
18
20
|
return models.getData("/films").filter(({id}) => parent.films.includes(id));
|
|
19
21
|
};
|
|
20
|
-
|
|
22
|
+
var starships = (parent, {id}, {models}) => {
|
|
21
23
|
return models.getData("/starships").filter(({id: id2}) => parent.starships.includes(id2));
|
|
22
24
|
};
|
|
23
25
|
function people(key) {
|
|
@@ -25,61 +27,58 @@ function people(key) {
|
|
|
25
27
|
return models.getData("/people").filter(({id}) => parent[key].includes(id));
|
|
26
28
|
};
|
|
27
29
|
}
|
|
28
|
-
|
|
30
|
+
var vehicles = (parent, args, {models}) => {
|
|
29
31
|
return models.getData("/vehicles").filter(({id}) => parent.vehicles.includes(id));
|
|
30
32
|
};
|
|
31
|
-
|
|
32
|
-
return models.getData("/transport").filter(({id}) => parent.starships.includes(id));
|
|
33
|
-
};
|
|
34
|
-
const planets = (parent, args, {models}) => {
|
|
33
|
+
var planets = (parent, args, {models}) => {
|
|
35
34
|
return models.getData("/planets").filter(({id}) => parent.planets.includes(id));
|
|
36
35
|
};
|
|
37
|
-
|
|
36
|
+
var species = (parent, args, {models}) => {
|
|
38
37
|
return models.getData("/species").filter(({id}) => parent.species.includes(id));
|
|
39
38
|
};
|
|
40
|
-
|
|
39
|
+
var homeworld = (parent, args, {models}) => {
|
|
41
40
|
return models.getData("/planets").find((planet2) => planet2.id === parent.homeworld);
|
|
42
41
|
};
|
|
43
|
-
|
|
42
|
+
var person = (parent, {id}, {models}) => {
|
|
44
43
|
return models.getData("/people").find((person2) => person2.id === id);
|
|
45
44
|
};
|
|
46
|
-
|
|
45
|
+
var planet = (parent, {id}, {models}) => {
|
|
47
46
|
return models.getData("/planets").find((planet2) => planet2.id === id);
|
|
48
47
|
};
|
|
49
|
-
|
|
48
|
+
var film = (parent, {id}, {models}) => {
|
|
50
49
|
return models.getData("/films").find((film2) => film2.id === id);
|
|
51
50
|
};
|
|
52
|
-
|
|
51
|
+
var starship = (parent, {id}, {models}) => {
|
|
53
52
|
return models.getData("/starships").find((starship2) => starship2.id === id);
|
|
54
53
|
};
|
|
55
|
-
|
|
54
|
+
var transport = (parent, {id}, {models}) => {
|
|
56
55
|
return models.getData("/transport").find((transport2) => transport2.id === id);
|
|
57
56
|
};
|
|
58
|
-
|
|
57
|
+
var vehicle = (parent, {id}, {models}) => {
|
|
59
58
|
return models.getData("/vehicles").find((vehicle2) => vehicle2.id === id);
|
|
60
59
|
};
|
|
61
|
-
|
|
60
|
+
var searchPeopleByName = (parent, {search}, {models}) => {
|
|
62
61
|
return models.getData("/people").filter((person2) => new RegExp(search, "i").test(person2.name));
|
|
63
62
|
};
|
|
64
|
-
|
|
63
|
+
var searchPlanetsByName = (parent, {search}, {models}) => {
|
|
65
64
|
return models.getData("/planets").filter((planet2) => new RegExp(search, "i").test(planet2.name));
|
|
66
65
|
};
|
|
67
|
-
|
|
66
|
+
var searchFilmsByTitle = (parent, {search}, {models}) => {
|
|
68
67
|
return models.getData("/films").filter((film2) => new RegExp(search, "i").test(film2.title));
|
|
69
68
|
};
|
|
70
|
-
|
|
69
|
+
var searchSpeciesByName = (parent, {search}, {models}) => {
|
|
71
70
|
return models.getData("/species").filter((species2) => new RegExp(search, "i").test(species2.name));
|
|
72
71
|
};
|
|
73
|
-
|
|
72
|
+
var searchStarshipsByName = (parent, {search}, {models}) => {
|
|
74
73
|
return models.getData("/starships").filter((starship2) => new RegExp(search, "i").test(starship2.name));
|
|
75
74
|
};
|
|
76
|
-
|
|
75
|
+
var searchVehiclesByName = (parent, {search}, {models}) => {
|
|
77
76
|
return models.getData("/vehicles").filter((vehicle2) => new RegExp(search, "i").test(vehicle2.name));
|
|
78
77
|
};
|
|
79
|
-
|
|
78
|
+
var searchTransportsByName = (parent, {search}, {models}) => {
|
|
80
79
|
return models.getData("/transport").filter((transport2) => new RegExp(search, "i").test(transport2.name));
|
|
81
80
|
};
|
|
82
|
-
|
|
81
|
+
var resolvers = {
|
|
83
82
|
SearchResult: {
|
|
84
83
|
__resolveType(parent) {
|
|
85
84
|
return parent.__typename;
|
|
@@ -224,7 +223,7 @@ const resolvers = {
|
|
|
224
223
|
cost_in_credits: (vehicle2) => +vehicle2.cost_in_credits
|
|
225
224
|
}
|
|
226
225
|
};
|
|
227
|
-
|
|
226
|
+
var forceNumber = (i) => Number(i.split(",").join("").split("-")[0]) || -1;
|
|
228
227
|
var resolvers_default = resolvers;
|
|
229
228
|
export {
|
|
230
229
|
resolvers_default as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supermassive.d.ts","sourceRoot":"","sources":["../../src/bin/supermassive.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"supermassive.d.ts","sourceRoot":"","sources":["../../src/bin/supermassive.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,OAAO,EAAE,MAAM,WAAW,CAAC;AAI7C,wBAAgB,YAAY,IAAI,OAAO,CAYtC"}
|
package/lib/bin/supermassive.mjs
CHANGED
|
@@ -18,11 +18,13 @@ var __async = (__this, __arguments, generator) => {
|
|
|
18
18
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
|
+
|
|
22
|
+
// src/bin/supermassive.ts
|
|
21
23
|
import path from "path";
|
|
22
24
|
import fs from "fs/promises";
|
|
23
25
|
import ts from "typescript";
|
|
24
26
|
import {program, Command} from "commander";
|
|
25
|
-
import {extractImplicitTypesToTypescript} from "../extractImplicitTypesToTypescript";
|
|
27
|
+
import {extractImplicitTypesToTypescript} from "../extractImplicitTypesToTypescript.mjs";
|
|
26
28
|
import {parse} from "graphql";
|
|
27
29
|
function supermassive() {
|
|
28
30
|
const command = new Command();
|
package/lib/collectFields.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeWithSchema.d.ts","sourceRoot":"","sources":["../src/executeWithSchema.ts"],"names":[],"mappings":"
|
|
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"}
|
package/lib/executeWithSchema.js
CHANGED
|
@@ -40,10 +40,10 @@ __export(exports, {
|
|
|
40
40
|
});
|
|
41
41
|
var import_schema = __toModule(require("@graphql-tools/schema"));
|
|
42
42
|
var import_graphql = __toModule(require("graphql"));
|
|
43
|
-
var
|
|
43
|
+
var import_index = __toModule(require("./index"));
|
|
44
44
|
function executeWithSchema({
|
|
45
45
|
typeDefs,
|
|
46
|
-
resolvers
|
|
46
|
+
resolvers,
|
|
47
47
|
document: rawDocument,
|
|
48
48
|
rootValue,
|
|
49
49
|
contextValue,
|
|
@@ -52,20 +52,20 @@ function executeWithSchema({
|
|
|
52
52
|
fieldResolver,
|
|
53
53
|
typeResolver
|
|
54
54
|
}) {
|
|
55
|
-
const schema = (0, import_schema.makeExecutableSchema)({typeDefs, resolvers
|
|
55
|
+
const schema = (0, import_schema.makeExecutableSchema)({typeDefs, resolvers});
|
|
56
56
|
let extractedResolvers = {};
|
|
57
57
|
const getTypeByName = (name) => {
|
|
58
|
-
const type =
|
|
58
|
+
const type = import_index.specifiedScalars[name] || extractedResolvers[name];
|
|
59
59
|
if ((0, import_graphql.isInputType)(type)) {
|
|
60
60
|
return type;
|
|
61
61
|
} else {
|
|
62
62
|
throw new Error("Invalid type");
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
-
extractedResolvers = (0,
|
|
66
|
-
const fullResolvers = __objSpread(__objSpread({}, extractedResolvers),
|
|
67
|
-
const document = (0,
|
|
68
|
-
return (0,
|
|
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
69
|
document,
|
|
70
70
|
resolvers: fullResolvers,
|
|
71
71
|
rootValue,
|
|
@@ -14,6 +14,8 @@ var __objSpread = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
+
|
|
18
|
+
// src/executeWithSchema.ts
|
|
17
19
|
import {makeExecutableSchema} from "@graphql-tools/schema";
|
|
18
20
|
import {isInputType} from "graphql";
|
|
19
21
|
import {
|
|
@@ -21,10 +23,10 @@ import {
|
|
|
21
23
|
executeWithoutSchema,
|
|
22
24
|
extractImplicitTypes,
|
|
23
25
|
specifiedScalars
|
|
24
|
-
} from ".";
|
|
26
|
+
} from "./index.mjs";
|
|
25
27
|
function executeWithSchema({
|
|
26
28
|
typeDefs,
|
|
27
|
-
resolvers
|
|
29
|
+
resolvers,
|
|
28
30
|
document: rawDocument,
|
|
29
31
|
rootValue,
|
|
30
32
|
contextValue,
|
|
@@ -33,7 +35,7 @@ function executeWithSchema({
|
|
|
33
35
|
fieldResolver,
|
|
34
36
|
typeResolver
|
|
35
37
|
}) {
|
|
36
|
-
const schema = makeExecutableSchema({typeDefs, resolvers
|
|
38
|
+
const schema = makeExecutableSchema({typeDefs, resolvers});
|
|
37
39
|
let extractedResolvers = {};
|
|
38
40
|
const getTypeByName = (name) => {
|
|
39
41
|
const type = specifiedScalars[name] || extractedResolvers[name];
|
|
@@ -44,7 +46,7 @@ function executeWithSchema({
|
|
|
44
46
|
}
|
|
45
47
|
};
|
|
46
48
|
extractedResolvers = extractImplicitTypes(typeDefs, getTypeByName);
|
|
47
|
-
const fullResolvers = __objSpread(__objSpread({}, extractedResolvers),
|
|
49
|
+
const fullResolvers = __objSpread(__objSpread({}, extractedResolvers), resolvers);
|
|
48
50
|
const document = addTypesToRequestDocument(schema, rawDocument);
|
|
49
51
|
return executeWithoutSchema({
|
|
50
52
|
document,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// src/executeWithoutSchema.ts
|
|
1
2
|
import {
|
|
2
3
|
GraphQLEnumType,
|
|
3
4
|
GraphQLError,
|
|
@@ -7,22 +8,22 @@ import {
|
|
|
7
8
|
Kind,
|
|
8
9
|
locatedError
|
|
9
10
|
} from "graphql";
|
|
10
|
-
import {collectFields} from "./collectFields";
|
|
11
|
-
import {devAssert} from "./jsutils/devAssert";
|
|
12
|
-
import {inspect} from "./jsutils/inspect";
|
|
13
|
-
import {invariant} from "./jsutils/invariant";
|
|
14
|
-
import {isIterableObject} from "./jsutils/isIterableObject";
|
|
15
|
-
import {isObjectLike} from "./jsutils/isObjectLike";
|
|
16
|
-
import {isPromise} from "./jsutils/isPromise";
|
|
17
|
-
import {addPath, pathToArray} from "./jsutils/Path";
|
|
18
|
-
import {promiseForObject} from "./jsutils/promiseForObject";
|
|
19
|
-
import {promiseReduce} from "./jsutils/promiseReduce";
|
|
20
|
-
import {typeNameFromAST} from "./utilities/typeNameFromAST";
|
|
11
|
+
import {collectFields} from "./collectFields.mjs";
|
|
12
|
+
import {devAssert} from "./jsutils/devAssert.mjs";
|
|
13
|
+
import {inspect} from "./jsutils/inspect.mjs";
|
|
14
|
+
import {invariant} from "./jsutils/invariant.mjs";
|
|
15
|
+
import {isIterableObject} from "./jsutils/isIterableObject.mjs";
|
|
16
|
+
import {isObjectLike} from "./jsutils/isObjectLike.mjs";
|
|
17
|
+
import {isPromise} from "./jsutils/isPromise.mjs";
|
|
18
|
+
import {addPath, pathToArray} from "./jsutils/Path.mjs";
|
|
19
|
+
import {promiseForObject} from "./jsutils/promiseForObject.mjs";
|
|
20
|
+
import {promiseReduce} from "./jsutils/promiseReduce.mjs";
|
|
21
|
+
import {typeNameFromAST} from "./utilities/typeNameFromAST.mjs";
|
|
21
22
|
import {
|
|
22
23
|
getArgumentValues,
|
|
23
24
|
getVariableValues,
|
|
24
25
|
specifiedScalars
|
|
25
|
-
} from "./values";
|
|
26
|
+
} from "./values.mjs";
|
|
26
27
|
function executeWithoutSchema(args) {
|
|
27
28
|
const {
|
|
28
29
|
resolvers,
|
|
@@ -318,9 +319,6 @@ function completeObjectValue(exeContext, returnTypeName, fieldNodes, info, path,
|
|
|
318
319
|
const subFieldNodes = collectSubfields(exeContext, returnTypeName, fieldNodes);
|
|
319
320
|
return executeFields(exeContext, returnTypeName, result, path, subFieldNodes);
|
|
320
321
|
}
|
|
321
|
-
function invalidReturnTypeError(returnType, result, fieldNodes) {
|
|
322
|
-
return new GraphQLError(`Expected value of type "${returnType.name}" but got: ${inspect(result)}.`, fieldNodes);
|
|
323
|
-
}
|
|
324
322
|
function collectSubfields(exeContext, returnTypeName, fieldNodes) {
|
|
325
323
|
let subFieldNodes = new Map();
|
|
326
324
|
const visitedFragmentNames = new Set();
|
|
@@ -331,12 +329,12 @@ function collectSubfields(exeContext, returnTypeName, fieldNodes) {
|
|
|
331
329
|
}
|
|
332
330
|
return subFieldNodes;
|
|
333
331
|
}
|
|
334
|
-
|
|
332
|
+
var defaultTypeResolver = function(value) {
|
|
335
333
|
if (isObjectLike(value) && typeof value.__typename === "string") {
|
|
336
334
|
return value.__typename;
|
|
337
335
|
}
|
|
338
336
|
};
|
|
339
|
-
|
|
337
|
+
var defaultFieldResolver = function(source, args, contextValue, info) {
|
|
340
338
|
if (isObjectLike(source) || typeof source === "function") {
|
|
341
339
|
const property = source[info.fieldName];
|
|
342
340
|
if (typeof property === "function") {
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { executeWithoutSchema } from "./executeWithoutSchema";
|
|
2
2
|
export { executeWithSchema } from "./executeWithSchema";
|
|
3
|
-
export { Resolvers } from "./types";
|
|
3
|
+
export type { Resolvers } from "./types";
|
|
4
4
|
export { addTypesToRequestDocument } from "./ast/addTypesToRequestDocument";
|
|
5
5
|
export { extractImplicitTypes } from "./extractImplicitTypesRuntime";
|
|
6
6
|
export { specifiedScalars } from "./values";
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAE,gCAAgC,EAAE,MAAM,+CAA+C,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -22,7 +22,6 @@ var __toModule = (module2) => {
|
|
|
22
22
|
};
|
|
23
23
|
__markAsModule(exports);
|
|
24
24
|
__export(exports, {
|
|
25
|
-
Resolvers: () => import_types.Resolvers,
|
|
26
25
|
addTypesToRequestDocument: () => import_addTypesToRequestDocument.addTypesToRequestDocument,
|
|
27
26
|
annotateDocumentGraphQLTransform: () => import_annotateDocumentGraphQLTransform.annotateDocumentGraphQLTransform,
|
|
28
27
|
executeWithSchema: () => import_executeWithSchema.executeWithSchema,
|
|
@@ -32,7 +31,6 @@ __export(exports, {
|
|
|
32
31
|
});
|
|
33
32
|
var import_executeWithoutSchema = __toModule(require("./executeWithoutSchema"));
|
|
34
33
|
var import_executeWithSchema = __toModule(require("./executeWithSchema"));
|
|
35
|
-
var import_types = __toModule(require("./types"));
|
|
36
34
|
var import_addTypesToRequestDocument = __toModule(require("./ast/addTypesToRequestDocument"));
|
|
37
35
|
var import_extractImplicitTypesRuntime = __toModule(require("./extractImplicitTypesRuntime"));
|
|
38
36
|
var import_values = __toModule(require("./values"));
|
package/lib/index.mjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {addTypesToRequestDocument} from "./ast/addTypesToRequestDocument";
|
|
5
|
-
import {extractImplicitTypes} from "./extractImplicitTypesRuntime";
|
|
6
|
-
import {specifiedScalars} from "./values";
|
|
7
|
-
import {annotateDocumentGraphQLTransform} from "./transforms/annotateDocumentGraphQLTransform";
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {executeWithoutSchema} from "./executeWithoutSchema.mjs";
|
|
3
|
+
import {executeWithSchema} from "./executeWithSchema.mjs";
|
|
4
|
+
import {addTypesToRequestDocument} from "./ast/addTypesToRequestDocument.mjs";
|
|
5
|
+
import {extractImplicitTypes} from "./extractImplicitTypesRuntime.mjs";
|
|
6
|
+
import {specifiedScalars} from "./values.mjs";
|
|
7
|
+
import {annotateDocumentGraphQLTransform} from "./transforms/annotateDocumentGraphQLTransform.mjs";
|
|
8
8
|
export {
|
|
9
|
-
Resolvers,
|
|
10
9
|
addTypesToRequestDocument,
|
|
11
10
|
annotateDocumentGraphQLTransform,
|
|
12
11
|
executeWithSchema,
|
package/lib/jsutils/Path.mjs
CHANGED
package/lib/jsutils/inspect.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/jsutils/instanceOf.ts
|
|
2
|
+
import {inspect} from "./inspect.mjs";
|
|
3
|
+
var instanceOf = false ? function instanceOf2(value, constructor) {
|
|
3
4
|
return value instanceof constructor;
|
|
4
5
|
} : function instanceOf3(value, constructor) {
|
|
5
6
|
var _a;
|
package/lib/jsutils/keyMap.mjs
CHANGED
package/lib/jsutils/mapValue.mjs
CHANGED
package/lib/jsutils/memoize3.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// src/jsutils/naturalCompare.ts
|
|
1
2
|
function naturalCompare(aStr, bStr) {
|
|
2
3
|
let aIndex = 0;
|
|
3
4
|
let bIndex = 0;
|
|
@@ -36,8 +37,8 @@ function naturalCompare(aStr, bStr) {
|
|
|
36
37
|
}
|
|
37
38
|
return aStr.length - bStr.length;
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
var DIGIT_0 = 48;
|
|
41
|
+
var DIGIT_9 = 57;
|
|
41
42
|
function isDigit(code) {
|
|
42
43
|
return !isNaN(code) && DIGIT_0 <= code && code <= DIGIT_9;
|
|
43
44
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// src/jsutils/suggestionList.ts
|
|
2
|
+
import {naturalCompare} from "./naturalCompare.mjs";
|
|
2
3
|
function suggestionList(input, options) {
|
|
3
4
|
const optionsByDistance = Object.create(null);
|
|
4
5
|
const lexicalDistance = new LexicalDistance(input);
|
|
@@ -14,7 +15,7 @@ function suggestionList(input, options) {
|
|
|
14
15
|
return distanceDiff !== 0 ? distanceDiff : naturalCompare(a, b);
|
|
15
16
|
});
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
+
var LexicalDistance = class {
|
|
18
19
|
constructor(input) {
|
|
19
20
|
this._input = input;
|
|
20
21
|
this._inputLowerCase = input.toLowerCase();
|
|
@@ -72,7 +73,7 @@ class LexicalDistance {
|
|
|
72
73
|
const distance = rows[aLength % 3][bLength];
|
|
73
74
|
return distance <= threshold ? distance : void 0;
|
|
74
75
|
}
|
|
75
|
-
}
|
|
76
|
+
};
|
|
76
77
|
function stringToArray(str) {
|
|
77
78
|
const strLength = str.length;
|
|
78
79
|
const array = new Array(strLength);
|
package/lib/jsutils/toObjMap.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
// src/transforms/annotateDocumentGraphQLTransform.ts
|
|
1
2
|
import {
|
|
2
3
|
Kind
|
|
3
4
|
} from "graphql";
|
|
4
|
-
import {addTypesToRequestDocument} from "../ast/addTypesToRequestDocument";
|
|
5
|
-
|
|
5
|
+
import {addTypesToRequestDocument} from "../ast/addTypesToRequestDocument.mjs";
|
|
6
|
+
var annotateDocumentGraphQLTransform = (schema) => {
|
|
6
7
|
return (node) => {
|
|
7
8
|
const document = addTypesToRequestDocument(schema, {
|
|
8
9
|
kind: Kind.DOCUMENT,
|
|
@@ -14,10 +14,16 @@ var __objSpread = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
+
|
|
18
|
+
// src/transforms/transformerTestUtils.ts
|
|
17
19
|
import Ts from "typescript";
|
|
18
|
-
import
|
|
20
|
+
import {
|
|
21
|
+
basename,
|
|
22
|
+
extname,
|
|
23
|
+
join
|
|
24
|
+
} from "path";
|
|
19
25
|
import {createProjectSync} from "@ts-morph/bootstrap";
|
|
20
|
-
|
|
26
|
+
var Transformer = class {
|
|
21
27
|
constructor() {
|
|
22
28
|
this.compilerOptions = {};
|
|
23
29
|
this.mocks = [];
|
|
@@ -92,8 +98,8 @@ class Transformer {
|
|
|
92
98
|
transforms: this.transformers
|
|
93
99
|
});
|
|
94
100
|
}
|
|
95
|
-
}
|
|
96
|
-
|
|
101
|
+
};
|
|
102
|
+
var transformFile = (file, options) => {
|
|
97
103
|
const project = options.project || createProjectSync({
|
|
98
104
|
useInMemoryFileSystem: true,
|
|
99
105
|
compilerOptions: getCompilerOptions(options.compilerOptions)
|
|
@@ -142,10 +148,10 @@ function getCompilerOptions(options) {
|
|
|
142
148
|
}
|
|
143
149
|
function getFileArtifactPath(file, program) {
|
|
144
150
|
const options = program.getCompilerOptions();
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
const artifactExtname =
|
|
148
|
-
return
|
|
151
|
+
const extname2 = extname(file.fileName);
|
|
152
|
+
const basename2 = basename(file.fileName, extname2);
|
|
153
|
+
const artifactExtname = extname2 === ".tsx" && options.jsx === Ts.JsxEmit.Preserve ? ".jsx" : ".js";
|
|
154
|
+
return join(options.outDir || ".", `${basename2}${artifactExtname}`);
|
|
149
155
|
}
|
|
150
156
|
export {
|
|
151
157
|
Transformer,
|
package/lib/values.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// src/values.ts
|
|
1
2
|
import {
|
|
2
3
|
GraphQLBoolean,
|
|
3
4
|
GraphQLError,
|
|
@@ -14,9 +15,9 @@ import {
|
|
|
14
15
|
valueFromAST,
|
|
15
16
|
coerceInputValue
|
|
16
17
|
} from "graphql";
|
|
17
|
-
import {inspect} from "./jsutils/inspect";
|
|
18
|
-
import {keyMap} from "./jsutils/keyMap";
|
|
19
|
-
import {printPathArray} from "./jsutils/printPathArray";
|
|
18
|
+
import {inspect} from "./jsutils/inspect.mjs";
|
|
19
|
+
import {keyMap} from "./jsutils/keyMap.mjs";
|
|
20
|
+
import {printPathArray} from "./jsutils/printPathArray.mjs";
|
|
20
21
|
function getVariableValues(resolvers, varDefNodes, inputs, options) {
|
|
21
22
|
const errors = [];
|
|
22
23
|
const maxErrors = options == null ? void 0 : options.maxErrors;
|
|
@@ -111,7 +112,7 @@ function getDirectiveValues(resolvers, node, variableValues) {
|
|
|
111
112
|
function hasOwnProperty(obj, prop) {
|
|
112
113
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
113
114
|
}
|
|
114
|
-
|
|
115
|
+
var specifiedScalars = {
|
|
115
116
|
ID: GraphQLID,
|
|
116
117
|
String: GraphQLString,
|
|
117
118
|
Int: GraphQLInt,
|