@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,37 @@
|
|
|
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
|
+
annotateDocumentGraphQLTransform: () => annotateDocumentGraphQLTransform
|
|
26
|
+
});
|
|
27
|
+
var import_graphql = __toModule(require("graphql"));
|
|
28
|
+
var import_addTypesToRequestDocument = __toModule(require("../ast/addTypesToRequestDocument"));
|
|
29
|
+
const annotateDocumentGraphQLTransform = (schema) => {
|
|
30
|
+
return (node) => {
|
|
31
|
+
const document = (0, import_addTypesToRequestDocument.addTypesToRequestDocument)(schema, {
|
|
32
|
+
kind: import_graphql.Kind.DOCUMENT,
|
|
33
|
+
definitions: [node]
|
|
34
|
+
});
|
|
35
|
+
return document.definitions[0];
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/transforms/annotateDocumentGraphQLTransform.ts
|
|
2
|
+
import {
|
|
3
|
+
Kind
|
|
4
|
+
} from "graphql";
|
|
5
|
+
import {addTypesToRequestDocument} from "../ast/addTypesToRequestDocument.mjs";
|
|
6
|
+
var annotateDocumentGraphQLTransform = (schema) => {
|
|
7
|
+
return (node) => {
|
|
8
|
+
const document = addTypesToRequestDocument(schema, {
|
|
9
|
+
kind: Kind.DOCUMENT,
|
|
10
|
+
definitions: [node]
|
|
11
|
+
});
|
|
12
|
+
return document.definitions[0];
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
annotateDocumentGraphQLTransform
|
|
17
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import Ts from "typescript";
|
|
2
|
+
import { Project } from "@ts-morph/bootstrap";
|
|
3
|
+
export declare type TransformerFn = (program: Ts.Program) => Ts.TransformerFactory<Ts.SourceFile>;
|
|
4
|
+
export declare class Transformer {
|
|
5
|
+
private compilerOptions;
|
|
6
|
+
private filePath?;
|
|
7
|
+
private file?;
|
|
8
|
+
private mocks;
|
|
9
|
+
private sources;
|
|
10
|
+
private transformers;
|
|
11
|
+
private project?;
|
|
12
|
+
private clone;
|
|
13
|
+
addMock(moduleDescriptor: ModuleDescriptor): Transformer;
|
|
14
|
+
addSource(source: File): Transformer;
|
|
15
|
+
addTransformer(transformer: TransformerFn): Transformer;
|
|
16
|
+
addTransformers(transformers: TransformerFn[]): Transformer;
|
|
17
|
+
setCompilerOptions(options: Ts.CompilerOptions): Transformer;
|
|
18
|
+
setFile(file: File): Transformer;
|
|
19
|
+
setFilePath(filePath: string): Transformer;
|
|
20
|
+
transform(input?: string): string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @alpha
|
|
24
|
+
*/
|
|
25
|
+
export interface ModuleDescriptor {
|
|
26
|
+
name: string;
|
|
27
|
+
content: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @alpha
|
|
31
|
+
*/
|
|
32
|
+
export interface File {
|
|
33
|
+
path: string;
|
|
34
|
+
contents: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @alpha
|
|
38
|
+
*/
|
|
39
|
+
export interface TransformFileOptions {
|
|
40
|
+
project?: Project;
|
|
41
|
+
sources?: ReadonlyArray<File>;
|
|
42
|
+
mocks?: ReadonlyArray<ModuleDescriptor>;
|
|
43
|
+
compilerOptions?: Partial<Ts.CompilerOptions>;
|
|
44
|
+
transforms: ((program: Ts.Program) => Ts.TransformerFactory<Ts.SourceFile>)[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Transform a TypeScript file given a project context and transform function
|
|
48
|
+
* in a virtual filesystem
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const file = {
|
|
53
|
+
* path: '/index.ts',
|
|
54
|
+
* contents: `
|
|
55
|
+
* import { world } from "./world";
|
|
56
|
+
* console.log("Hello,", world);
|
|
57
|
+
* `
|
|
58
|
+
* };
|
|
59
|
+
*
|
|
60
|
+
* const sources = [
|
|
61
|
+
* {
|
|
62
|
+
* path: '/world.ts',
|
|
63
|
+
* contents: `export const world = 'World'`
|
|
64
|
+
* }
|
|
65
|
+
* ];
|
|
66
|
+
*
|
|
67
|
+
* transformFile(file, {
|
|
68
|
+
* sources,
|
|
69
|
+
* transform() { ... }
|
|
70
|
+
* })
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @alpha
|
|
74
|
+
* @param file - File to use as project root
|
|
75
|
+
* @param options - Options providing context to the transformation
|
|
76
|
+
*/
|
|
77
|
+
export declare const transformFile: (file: File, options: TransformFileOptions) => string;
|
|
78
|
+
export declare function getCompilerOptions(options?: Partial<Ts.CompilerOptions>): Ts.CompilerOptions;
|
|
79
|
+
//# sourceMappingUR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AAM,CAAC;IAEb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IAEnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,OAAO,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAE9B,KAAK,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAExC,eAAe,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;IAE9C,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;CAC/E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,aAAa,SAClB,IAAI,WACD,oBAAoB,KAC5B,MAwDF,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,eAAe,CAAC,GACpC,EAAE,CAAC,eAAe,CAepB"}
|
|
@@ -0,0 +1,175 @@
|
|
|
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 __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
10
|
+
var __objSpread = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
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
|
+
};
|
|
26
|
+
var __reExport = (target, module2, desc) => {
|
|
27
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
28
|
+
for (let key of __getOwnPropNames(module2))
|
|
29
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
30
|
+
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
31
|
+
}
|
|
32
|
+
return target;
|
|
33
|
+
};
|
|
34
|
+
var __toModule = (module2) => {
|
|
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);
|
|
36
|
+
};
|
|
37
|
+
__markAsModule(exports);
|
|
38
|
+
__export(exports, {
|
|
39
|
+
Transformer: () => Transformer,
|
|
40
|
+
getCompilerOptions: () => getCompilerOptions,
|
|
41
|
+
transformFile: () => transformFile
|
|
42
|
+
});
|
|
43
|
+
var import_typescript = __toModule(require("typescript"));
|
|
44
|
+
var Path = __toModule(require("path"));
|
|
45
|
+
var import_bootstrap = __toModule(require("@ts-morph/bootstrap"));
|
|
46
|
+
class Transformer {
|
|
47
|
+
constructor() {
|
|
48
|
+
this.compilerOptions = {};
|
|
49
|
+
this.mocks = [];
|
|
50
|
+
this.sources = [];
|
|
51
|
+
this.transformers = [];
|
|
52
|
+
}
|
|
53
|
+
clone() {
|
|
54
|
+
const target = new Transformer();
|
|
55
|
+
for (const prop in this) {
|
|
56
|
+
if (this.hasOwnProperty(prop)) {
|
|
57
|
+
target[prop] = this[prop];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return target;
|
|
61
|
+
}
|
|
62
|
+
addMock(moduleDescriptor) {
|
|
63
|
+
const clone = this.clone();
|
|
64
|
+
clone.mocks.push(moduleDescriptor);
|
|
65
|
+
return clone;
|
|
66
|
+
}
|
|
67
|
+
addSource(source) {
|
|
68
|
+
const clone = this.clone();
|
|
69
|
+
clone.sources.push(source);
|
|
70
|
+
return clone;
|
|
71
|
+
}
|
|
72
|
+
addTransformer(transformer) {
|
|
73
|
+
const clone = this.clone();
|
|
74
|
+
clone.transformers.push(transformer);
|
|
75
|
+
return clone;
|
|
76
|
+
}
|
|
77
|
+
addTransformers(transformers) {
|
|
78
|
+
const clone = this.clone();
|
|
79
|
+
clone.transformers.push(...transformers);
|
|
80
|
+
return clone;
|
|
81
|
+
}
|
|
82
|
+
setCompilerOptions(options) {
|
|
83
|
+
const clone = this.clone();
|
|
84
|
+
clone.compilerOptions = options;
|
|
85
|
+
if (clone.project) {
|
|
86
|
+
clone.project = (0, import_bootstrap.createProjectSync)({
|
|
87
|
+
useInMemoryFileSystem: true,
|
|
88
|
+
compilerOptions: getCompilerOptions(clone.compilerOptions)
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return clone;
|
|
92
|
+
}
|
|
93
|
+
setFile(file) {
|
|
94
|
+
const clone = this.clone();
|
|
95
|
+
clone.file = file;
|
|
96
|
+
return clone;
|
|
97
|
+
}
|
|
98
|
+
setFilePath(filePath) {
|
|
99
|
+
const clone = this.clone();
|
|
100
|
+
clone.filePath = filePath;
|
|
101
|
+
return clone;
|
|
102
|
+
}
|
|
103
|
+
transform(input) {
|
|
104
|
+
this.project = this.project || (0, import_bootstrap.createProjectSync)({
|
|
105
|
+
useInMemoryFileSystem: true,
|
|
106
|
+
compilerOptions: getCompilerOptions(this.compilerOptions)
|
|
107
|
+
});
|
|
108
|
+
const filePath = typeof this.filePath === "string" ? this.filePath : "/index.ts";
|
|
109
|
+
const file = typeof input === "string" ? {path: filePath, contents: input} : this.file;
|
|
110
|
+
if (!file) {
|
|
111
|
+
throw new Error(`transform must be called on Transformer with file or with string input`);
|
|
112
|
+
}
|
|
113
|
+
return transformFile(file, {
|
|
114
|
+
project: this.project,
|
|
115
|
+
compilerOptions: this.compilerOptions,
|
|
116
|
+
mocks: this.mocks,
|
|
117
|
+
sources: this.sources,
|
|
118
|
+
transforms: this.transformers
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const transformFile = (file, options) => {
|
|
123
|
+
const project = options.project || (0, import_bootstrap.createProjectSync)({
|
|
124
|
+
useInMemoryFileSystem: true,
|
|
125
|
+
compilerOptions: getCompilerOptions(options.compilerOptions)
|
|
126
|
+
});
|
|
127
|
+
project.createSourceFile(file.path, file.contents);
|
|
128
|
+
(options.sources || []).forEach((source) => project.createSourceFile(source.path, source.contents));
|
|
129
|
+
(options.mocks || []).forEach((mock) => {
|
|
130
|
+
const base = `/node_modules/${mock.name}`;
|
|
131
|
+
project.createSourceFile(`${base}/index.ts`, mock.content);
|
|
132
|
+
project.fileSystem.writeFileSync(`${base}/package.json`, JSON.stringify({name: mock.name, main: "./src/index.ts"}));
|
|
133
|
+
});
|
|
134
|
+
const program = project.createProgram();
|
|
135
|
+
const {emitSkipped, diagnostics} = program.emit(program.getSourceFile(file.path), void 0, void 0, false, {
|
|
136
|
+
before: options.transforms.map((t) => t(program))
|
|
137
|
+
});
|
|
138
|
+
if (emitSkipped) {
|
|
139
|
+
throw new Error(project.formatDiagnosticsWithColorAndContext(diagnostics));
|
|
140
|
+
}
|
|
141
|
+
const inFile = program.getSourceFile(file.path);
|
|
142
|
+
if (!inFile) {
|
|
143
|
+
throw new Error(`Could not get SourceFile for ${file.path}`);
|
|
144
|
+
}
|
|
145
|
+
if (!inFile) {
|
|
146
|
+
throw new Error(`Could not determine ArtifactFile for ${file.path}`);
|
|
147
|
+
}
|
|
148
|
+
const fileArtifactPath = getFileArtifactPath(inFile, program);
|
|
149
|
+
if (!fileArtifactPath) {
|
|
150
|
+
throw new Error(`Could not determine fileArtifactPath for ${file.path}`);
|
|
151
|
+
}
|
|
152
|
+
return String(project.fileSystem.readFileSync(fileArtifactPath));
|
|
153
|
+
};
|
|
154
|
+
function getCompilerOptions(options) {
|
|
155
|
+
return __objSpread({
|
|
156
|
+
outDir: "/dist",
|
|
157
|
+
lib: ["/node_modules/typescript/lib/lib.esnext.full.d.ts"],
|
|
158
|
+
module: import_typescript.default.ModuleKind.ESNext,
|
|
159
|
+
moduleResolution: import_typescript.default.ModuleResolutionKind.NodeJs,
|
|
160
|
+
suppressImplicitAnyIndexErrors: true,
|
|
161
|
+
resolveJsonModule: true,
|
|
162
|
+
skipLibCheck: true,
|
|
163
|
+
target: import_typescript.default.ScriptTarget.ESNext,
|
|
164
|
+
types: [],
|
|
165
|
+
noEmitOnError: true,
|
|
166
|
+
jsx: import_typescript.default.JsxEmit.Preserve
|
|
167
|
+
}, options || {});
|
|
168
|
+
}
|
|
169
|
+
function getFileArtifactPath(file, program) {
|
|
170
|
+
const options = program.getCompilerOptions();
|
|
171
|
+
const extname = Path.extname(file.fileName);
|
|
172
|
+
const basename = Path.basename(file.fileName, extname);
|
|
173
|
+
const artifactExtname = extname === ".tsx" && options.jsx === import_typescript.default.JsxEmit.Preserve ? ".jsx" : ".js";
|
|
174
|
+
return Path.join(options.outDir || ".", `${basename}${artifactExtname}`);
|
|
175
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
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/transforms/transformerTestUtils.ts
|
|
19
|
+
import Ts from "typescript";
|
|
20
|
+
import {
|
|
21
|
+
basename,
|
|
22
|
+
extname,
|
|
23
|
+
join
|
|
24
|
+
} from "path";
|
|
25
|
+
import {createProjectSync} from "@ts-morph/bootstrap";
|
|
26
|
+
var Transformer = class {
|
|
27
|
+
constructor() {
|
|
28
|
+
this.compilerOptions = {};
|
|
29
|
+
this.mocks = [];
|
|
30
|
+
this.sources = [];
|
|
31
|
+
this.transformers = [];
|
|
32
|
+
}
|
|
33
|
+
clone() {
|
|
34
|
+
const target = new Transformer();
|
|
35
|
+
for (const prop in this) {
|
|
36
|
+
if (this.hasOwnProperty(prop)) {
|
|
37
|
+
target[prop] = this[prop];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return target;
|
|
41
|
+
}
|
|
42
|
+
addMock(moduleDescriptor) {
|
|
43
|
+
const clone = this.clone();
|
|
44
|
+
clone.mocks.push(moduleDescriptor);
|
|
45
|
+
return clone;
|
|
46
|
+
}
|
|
47
|
+
addSource(source) {
|
|
48
|
+
const clone = this.clone();
|
|
49
|
+
clone.sources.push(source);
|
|
50
|
+
return clone;
|
|
51
|
+
}
|
|
52
|
+
addTransformer(transformer) {
|
|
53
|
+
const clone = this.clone();
|
|
54
|
+
clone.transformers.push(transformer);
|
|
55
|
+
return clone;
|
|
56
|
+
}
|
|
57
|
+
addTransformers(transformers) {
|
|
58
|
+
const clone = this.clone();
|
|
59
|
+
clone.transformers.push(...transformers);
|
|
60
|
+
return clone;
|
|
61
|
+
}
|
|
62
|
+
setCompilerOptions(options) {
|
|
63
|
+
const clone = this.clone();
|
|
64
|
+
clone.compilerOptions = options;
|
|
65
|
+
if (clone.project) {
|
|
66
|
+
clone.project = createProjectSync({
|
|
67
|
+
useInMemoryFileSystem: true,
|
|
68
|
+
compilerOptions: getCompilerOptions(clone.compilerOptions)
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return clone;
|
|
72
|
+
}
|
|
73
|
+
setFile(file) {
|
|
74
|
+
const clone = this.clone();
|
|
75
|
+
clone.file = file;
|
|
76
|
+
return clone;
|
|
77
|
+
}
|
|
78
|
+
setFilePath(filePath) {
|
|
79
|
+
const clone = this.clone();
|
|
80
|
+
clone.filePath = filePath;
|
|
81
|
+
return clone;
|
|
82
|
+
}
|
|
83
|
+
transform(input) {
|
|
84
|
+
this.project = this.project || createProjectSync({
|
|
85
|
+
useInMemoryFileSystem: true,
|
|
86
|
+
compilerOptions: getCompilerOptions(this.compilerOptions)
|
|
87
|
+
});
|
|
88
|
+
const filePath = typeof this.filePath === "string" ? this.filePath : "/index.ts";
|
|
89
|
+
const file = typeof input === "string" ? {path: filePath, contents: input} : this.file;
|
|
90
|
+
if (!file) {
|
|
91
|
+
throw new Error(`transform must be called on Transformer with file or with string input`);
|
|
92
|
+
}
|
|
93
|
+
return transformFile(file, {
|
|
94
|
+
project: this.project,
|
|
95
|
+
compilerOptions: this.compilerOptions,
|
|
96
|
+
mocks: this.mocks,
|
|
97
|
+
sources: this.sources,
|
|
98
|
+
transforms: this.transformers
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var transformFile = (file, options) => {
|
|
103
|
+
const project = options.project || createProjectSync({
|
|
104
|
+
useInMemoryFileSystem: true,
|
|
105
|
+
compilerOptions: getCompilerOptions(options.compilerOptions)
|
|
106
|
+
});
|
|
107
|
+
project.createSourceFile(file.path, file.contents);
|
|
108
|
+
(options.sources || []).forEach((source) => project.createSourceFile(source.path, source.contents));
|
|
109
|
+
(options.mocks || []).forEach((mock) => {
|
|
110
|
+
const base = `/node_modules/${mock.name}`;
|
|
111
|
+
project.createSourceFile(`${base}/index.ts`, mock.content);
|
|
112
|
+
project.fileSystem.writeFileSync(`${base}/package.json`, JSON.stringify({name: mock.name, main: "./src/index.ts"}));
|
|
113
|
+
});
|
|
114
|
+
const program = project.createProgram();
|
|
115
|
+
const {emitSkipped, diagnostics} = program.emit(program.getSourceFile(file.path), void 0, void 0, false, {
|
|
116
|
+
before: options.transforms.map((t) => t(program))
|
|
117
|
+
});
|
|
118
|
+
if (emitSkipped) {
|
|
119
|
+
throw new Error(project.formatDiagnosticsWithColorAndContext(diagnostics));
|
|
120
|
+
}
|
|
121
|
+
const inFile = program.getSourceFile(file.path);
|
|
122
|
+
if (!inFile) {
|
|
123
|
+
throw new Error(`Could not get SourceFile for ${file.path}`);
|
|
124
|
+
}
|
|
125
|
+
if (!inFile) {
|
|
126
|
+
throw new Error(`Could not determine ArtifactFile for ${file.path}`);
|
|
127
|
+
}
|
|
128
|
+
const fileArtifactPath = getFileArtifactPath(inFile, program);
|
|
129
|
+
if (!fileArtifactPath) {
|
|
130
|
+
throw new Error(`Could not determine fileArtifactPath for ${file.path}`);
|
|
131
|
+
}
|
|
132
|
+
return String(project.fileSystem.readFileSync(fileArtifactPath));
|
|
133
|
+
};
|
|
134
|
+
function getCompilerOptions(options) {
|
|
135
|
+
return __objSpread({
|
|
136
|
+
outDir: "/dist",
|
|
137
|
+
lib: ["/node_modules/typescript/lib/lib.esnext.full.d.ts"],
|
|
138
|
+
module: Ts.ModuleKind.ESNext,
|
|
139
|
+
moduleResolution: Ts.ModuleResolutionKind.NodeJs,
|
|
140
|
+
suppressImplicitAnyIndexErrors: true,
|
|
141
|
+
resolveJsonModule: true,
|
|
142
|
+
skipLibCheck: true,
|
|
143
|
+
target: Ts.ScriptTarget.ESNext,
|
|
144
|
+
types: [],
|
|
145
|
+
noEmitOnError: true,
|
|
146
|
+
jsx: Ts.JsxEmit.Preserve
|
|
147
|
+
}, options || {});
|
|
148
|
+
}
|
|
149
|
+
function getFileArtifactPath(file, program) {
|
|
150
|
+
const options = program.getCompilerOptions();
|
|
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}`);
|
|
155
|
+
}
|
|
156
|
+
export {
|
|
157
|
+
Transformer,
|
|
158
|
+
getCompilerOptions,
|
|
159
|
+
transformFile
|
|
160
|
+
};
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { GraphQLEnumType, GraphQLError, GraphQLFormattedError, GraphQLInputObjectType, GraphQLScalarType, DocumentNode as UntypedDocumentNode } from "graphql";
|
|
2
|
+
import { Maybe } from "./jsutils/Maybe";
|
|
3
|
+
import { PromiseOrValue } from "./jsutils/PromiseOrValue";
|
|
4
|
+
import { DocumentNode, FieldNode, FragmentDefinitionNode, OperationDefinitionNode, TypeNode } from "./ast/TypedAST";
|
|
5
|
+
import { ObjMap } from "./jsutils/ObjMap";
|
|
6
|
+
import { Path } from "./jsutils/Path";
|
|
7
|
+
export declare type ScalarTypeResolver = GraphQLScalarType;
|
|
8
|
+
export declare type EnumTypeResolver = GraphQLEnumType;
|
|
9
|
+
export declare type FieldResolver<TSource, TContext, TArgs = Record<string, any>, TReturn = any> = (source: TSource, args: TArgs, context: TContext, info: ResolveInfo) => TReturn;
|
|
10
|
+
export declare type TypeResolver<TSource, TContext> = (value: TSource, context: TContext, info: ResolveInfo) => PromiseOrValue<Maybe<string>>;
|
|
11
|
+
export declare type ObjectTypeResolver<TSource = any, TContext = any, TArgs = any> = {
|
|
12
|
+
[key: string]: FieldResolver<TSource, TContext, TArgs>;
|
|
13
|
+
};
|
|
14
|
+
export declare type InterfaceTypeResolver<TSource = any, TContext = any, TArgs = any> = {
|
|
15
|
+
[key: string]: FieldResolver<TSource, TContext, TArgs>;
|
|
16
|
+
} & {
|
|
17
|
+
__resolveType?: TypeResolver<any, any>;
|
|
18
|
+
};
|
|
19
|
+
export declare type UnionTypeResolver = {
|
|
20
|
+
__resolveType?: TypeResolver<any, any>;
|
|
21
|
+
};
|
|
22
|
+
export declare type InputObjectTypeResolver = GraphQLInputObjectType;
|
|
23
|
+
export declare type Resolver<TSource, TContext> = ObjectTypeResolver<TSource, TContext> | InterfaceTypeResolver<TSource, TContext> | UnionTypeResolver | ScalarTypeResolver | EnumTypeResolver | InputObjectTypeResolver;
|
|
24
|
+
export declare type Resolvers<TSource = any, TContext = any> = Record<string, Resolver<TSource, TContext>>;
|
|
25
|
+
export interface ResolveInfo {
|
|
26
|
+
fieldName: string;
|
|
27
|
+
fieldNodes: Array<FieldNode>;
|
|
28
|
+
returnTypeName: string;
|
|
29
|
+
parentTypeName: string;
|
|
30
|
+
returnTypeNode: TypeNode;
|
|
31
|
+
path: Path;
|
|
32
|
+
fragments: ObjMap<FragmentDefinitionNode>;
|
|
33
|
+
rootValue: unknown;
|
|
34
|
+
operation: OperationDefinitionNode;
|
|
35
|
+
variableValues: {
|
|
36
|
+
[variable: string]: unknown;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The result of GraphQL execution.
|
|
41
|
+
*
|
|
42
|
+
* - `errors` is included when any errors occurred as a non-empty array.
|
|
43
|
+
* - `data` is the result of a successful execution of the query.
|
|
44
|
+
* - `extensions` is reserved for adding non-standard properties.
|
|
45
|
+
*/
|
|
46
|
+
export interface ExecutionResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> {
|
|
47
|
+
errors?: Array<GraphQLError>;
|
|
48
|
+
data?: TData | null;
|
|
49
|
+
extensions?: TExtensions;
|
|
50
|
+
}
|
|
51
|
+
export interface FormattedExecutionResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> {
|
|
52
|
+
errors?: Array<GraphQLFormattedError>;
|
|
53
|
+
data?: TData | null;
|
|
54
|
+
extensions?: TExtensions;
|
|
55
|
+
}
|
|
56
|
+
export interface CommonExecutionArgs {
|
|
57
|
+
resolvers: Resolvers;
|
|
58
|
+
rootValue?: unknown;
|
|
59
|
+
contextValue?: unknown;
|
|
60
|
+
variableValues?: Maybe<{
|
|
61
|
+
[variable: string]: unknown;
|
|
62
|
+
}>;
|
|
63
|
+
operationName?: Maybe<string>;
|
|
64
|
+
fieldResolver?: Maybe<FieldResolver<any, any>>;
|
|
65
|
+
typeResolver?: Maybe<TypeResolver<any, any>>;
|
|
66
|
+
}
|
|
67
|
+
export declare type ExecutionWithoutSchemaArgs = CommonExecutionArgs & {
|
|
68
|
+
document: DocumentNode;
|
|
69
|
+
};
|
|
70
|
+
export declare type ExecutionWithSchemaArgs = CommonExecutionArgs & {
|
|
71
|
+
document: UntypedDocumentNode;
|
|
72
|
+
typeDefs: UntypedDocumentNode;
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,YAAY,EACZ,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EAEjB,YAAY,IAAI,mBAAmB,EACpC,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EACL,YAAY,EACZ,SAAS,EACT,sBAAsB,EACtB,uBAAuB,EACvB,QAAQ,EACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MA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,IAAI,CAAC;IACpB,UAAU,CAAC,EAAE,WAAW,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,KAAK,CAAC;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC,CAAC;IACxD,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,aAAa,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAC/C,YAAY,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;CAC9C;AACD,oBAAY,0BAA0B,GAAG,mBAAmB,GAAG;IAC7D,QAAQ,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF,oBAAY,uBAAuB,GAAG,mBAAmB,GAAG;IAC1D,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,QAAQ,EAAE,mBAAmB,CAAC;CAC/B,CAAC"}
|
package/lib/types.js
ADDED
package/lib/types.mjs
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeNameFromAST.d.ts","sourceRoot":"","sources":["../../src/utilities/typeNameFromAST.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,wBAAgB,eAAe,CAAC,OAAO,EAAE,QAAQ,GAAG,MAAM,CAMzD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
typeNameFromAST: () => typeNameFromAST
|
|
26
|
+
});
|
|
27
|
+
var import_graphql = __toModule(require("graphql"));
|
|
28
|
+
function typeNameFromAST(typeAst) {
|
|
29
|
+
if (typeAst.kind === import_graphql.Kind.LIST_TYPE || typeAst.kind === import_graphql.Kind.NON_NULL_TYPE) {
|
|
30
|
+
return typeNameFromAST(typeAst.type);
|
|
31
|
+
} else {
|
|
32
|
+
return typeAst.name.value;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/utilities/typeNameFromAST.ts
|
|
2
|
+
import {Kind} from "graphql";
|
|
3
|
+
function typeNameFromAST(typeAst) {
|
|
4
|
+
if (typeAst.kind === Kind.LIST_TYPE || typeAst.kind === Kind.NON_NULL_TYPE) {
|
|
5
|
+
return typeNameFromAST(typeAst.type);
|
|
6
|
+
} else {
|
|
7
|
+
return typeAst.name.value;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
typeNameFromAST
|
|
12
|
+
};
|