@eddeee888/gcg-typescript-resolver-files 0.4.1 → 0.6.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/README.md +66 -0
- package/package.json +7 -7
- package/src/addVirtualTypesFileToTsMorphProject/addVirtualTypesFileToTsMorphProject.d.ts +2 -1
- package/src/addVirtualTypesFileToTsMorphProject/addVirtualTypesFileToTsMorphProject.js.map +1 -1
- package/src/defineConfig.d.ts +3 -2
- package/src/defineConfig.js +3 -2
- package/src/defineConfig.js.map +1 -1
- package/src/generateResolverFiles/addExternalResolverImport.js +2 -1
- package/src/generateResolverFiles/addExternalResolverImport.js.map +1 -1
- package/src/generateResolverFiles/addResolverMainFiles.d.ts +10 -0
- package/src/generateResolverFiles/{addResolverMainFile.js → addResolverMainFiles.js} +14 -5
- package/src/generateResolverFiles/addResolverMainFiles.js.map +1 -0
- package/src/generateResolverFiles/generateResolverFiles.js +7 -5
- package/src/generateResolverFiles/generateResolverFiles.js.map +1 -1
- package/src/generateResolverFiles/handleGraphQLInterfaceType.d.ts +2 -0
- package/src/generateResolverFiles/handleGraphQLInterfaceType.js +30 -0
- package/src/generateResolverFiles/handleGraphQLInterfaceType.js.map +1 -0
- package/src/generateResolverFiles/handleGraphQLObjectType.js +5 -1
- package/src/generateResolverFiles/handleGraphQLObjectType.js.map +1 -1
- package/src/generateResolverFiles/handleGraphQLRootObjectTypeField.js +7 -1
- package/src/generateResolverFiles/handleGraphQLRootObjectTypeField.js.map +1 -1
- package/src/generateResolverFiles/handleGraphQLScalarType.js +19 -3
- package/src/generateResolverFiles/handleGraphQLScalarType.js.map +1 -1
- package/src/generateResolverFiles/handleGraphQLUnionType.d.ts +2 -0
- package/src/generateResolverFiles/{handleGraphQLUninionType.js → handleGraphQLUnionType.js} +9 -5
- package/src/generateResolverFiles/handleGraphQLUnionType.js.map +1 -0
- package/src/generateResolverFiles/types.d.ts +3 -1
- package/src/generateResolverFiles/visitNamedType.d.ts +1 -0
- package/src/generateResolverFiles/visitNamedType.js +5 -0
- package/src/generateResolverFiles/visitNamedType.js.map +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +3 -1
- package/src/index.js.map +1 -1
- package/src/parseGraphQLSchema/parseGraphQLSchema.d.ts +9 -3
- package/src/parseGraphQLSchema/parseGraphQLSchema.js +61 -13
- package/src/parseGraphQLSchema/parseGraphQLSchema.js.map +1 -1
- package/src/parseTypeMappers/collectTypeMappersFromSourceFile.js +19 -0
- package/src/parseTypeMappers/collectTypeMappersFromSourceFile.js.map +1 -1
- package/src/preset.js +14 -5
- package/src/preset.js.map +1 -1
- package/src/utils/getNodePropertyMap.js +26 -0
- package/src/utils/getNodePropertyMap.js.map +1 -1
- package/src/utils/printImportLine.d.ts +10 -1
- package/src/utils/printImportLine.js +6 -3
- package/src/utils/printImportLine.js.map +1 -1
- package/src/validateAndMergeParsedConfigs/index.d.ts +1 -0
- package/src/validateAndMergeParsedConfigs/index.js +5 -0
- package/src/validateAndMergeParsedConfigs/index.js.map +1 -0
- package/src/validateAndMergeParsedConfigs/validateAndMergeParsedConfigs.d.ts +18 -0
- package/src/validateAndMergeParsedConfigs/validateAndMergeParsedConfigs.js +24 -0
- package/src/validateAndMergeParsedConfigs/validateAndMergeParsedConfigs.js.map +1 -0
- package/src/validatePresetConfig/validatePresetConfig.d.ts +29 -4
- package/src/validatePresetConfig/validatePresetConfig.js +55 -9
- package/src/validatePresetConfig/validatePresetConfig.js.map +1 -1
- package/src/generateResolverFiles/addResolverMainFile.d.ts +0 -5
- package/src/generateResolverFiles/addResolverMainFile.js.map +0 -1
- package/src/generateResolverFiles/handleGraphQLUninionType.d.ts +0 -2
- package/src/generateResolverFiles/handleGraphQLUninionType.js.map +0 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { GraphQLSchema } from 'graphql';
|
|
2
2
|
import type { ParseSourcesResult } from '../parseSources';
|
|
3
3
|
import type { TypeMappersMap } from '../parseTypeMappers';
|
|
4
|
-
import type { ParsedPresetConfig } from '../validatePresetConfig';
|
|
4
|
+
import type { ParsedPresetConfig, ScalarsOverridesType } from '../validatePresetConfig';
|
|
5
5
|
interface ParseGraphQLSchemaParams {
|
|
6
6
|
schemaAst: GraphQLSchema;
|
|
7
7
|
sourceMap: ParseSourcesResult['sourceMap'];
|
|
8
8
|
typeMappersMap: TypeMappersMap;
|
|
9
|
+
scalarsModule: ParsedPresetConfig['scalarsModule'];
|
|
10
|
+
scalarsOverrides: ParsedPresetConfig['scalarsOverrides'];
|
|
9
11
|
whitelistedModules: ParsedPresetConfig['whitelistedModules'];
|
|
10
12
|
blacklistedModules: ParsedPresetConfig['blacklistedModules'];
|
|
11
13
|
}
|
|
@@ -14,7 +16,11 @@ export interface ParsedGraphQLSchemaMeta {
|
|
|
14
16
|
object: Record<string, true>;
|
|
15
17
|
scalar: Record<string, true>;
|
|
16
18
|
};
|
|
17
|
-
pluginsConfig:
|
|
19
|
+
pluginsConfig: {
|
|
20
|
+
defaultScalarTypesMap: Record<string, ScalarsOverridesType>;
|
|
21
|
+
defaultScalarExternalResolvers: Record<string, string>;
|
|
22
|
+
defaultTypeMappers: Record<string, string>;
|
|
23
|
+
};
|
|
18
24
|
}
|
|
19
|
-
export declare const parseGraphQLSchema: ({ schemaAst, sourceMap, typeMappersMap, whitelistedModules, blacklistedModules, }: ParseGraphQLSchemaParams) => ParsedGraphQLSchemaMeta
|
|
25
|
+
export declare const parseGraphQLSchema: ({ schemaAst, sourceMap, typeMappersMap, scalarsModule, scalarsOverrides, whitelistedModules, blacklistedModules, }: ParseGraphQLSchemaParams) => Promise<ParsedGraphQLSchemaMeta>;
|
|
20
26
|
export {};
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseGraphQLSchema = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const graphql_1 = require("graphql");
|
|
5
|
-
const graphql_scalars_1 = require("graphql-scalars");
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
|
-
const parseGraphQLSchema = ({ schemaAst, sourceMap, typeMappersMap, whitelistedModules, blacklistedModules, }) => {
|
|
7
|
+
const parseGraphQLSchema = ({ schemaAst, sourceMap, typeMappersMap, scalarsModule, scalarsOverrides, whitelistedModules, blacklistedModules, }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
8
|
+
const scalarResolverMap = scalarsModule
|
|
9
|
+
? yield getScalarResolverMapFromModule(scalarsModule)
|
|
10
|
+
: {};
|
|
8
11
|
return Object.entries(schemaAst.getTypeMap()).reduce((res, [schemaType, namedType]) => {
|
|
9
12
|
var _a;
|
|
10
13
|
if ((0, utils_1.isNativeNamedType)(namedType)) {
|
|
14
|
+
if ((0, graphql_1.isSpecifiedScalarType)(namedType)) {
|
|
15
|
+
handleNativeScalarType({ schemaType, result: res, scalarsOverrides });
|
|
16
|
+
}
|
|
11
17
|
return res;
|
|
12
18
|
}
|
|
13
19
|
const parsedSource = (0, utils_1.parseLocationForWhitelistedModule)({
|
|
@@ -21,7 +27,13 @@ const parseGraphQLSchema = ({ schemaAst, sourceMap, typeMappersMap, whitelistedM
|
|
|
21
27
|
}
|
|
22
28
|
if ((0, graphql_1.isScalarType)(namedType)) {
|
|
23
29
|
res.userDefinedSchemaTypeMap.scalar[schemaType] = true;
|
|
24
|
-
handleScalarType(
|
|
30
|
+
handleScalarType({
|
|
31
|
+
scalarResolverMap,
|
|
32
|
+
schemaType,
|
|
33
|
+
scalarsModule,
|
|
34
|
+
scalarsOverrides,
|
|
35
|
+
result: res,
|
|
36
|
+
});
|
|
25
37
|
}
|
|
26
38
|
if (!(0, utils_1.isRootObjectType)(schemaType) && (0, graphql_1.isObjectType)(namedType)) {
|
|
27
39
|
res.userDefinedSchemaTypeMap.object[schemaType] = true;
|
|
@@ -44,18 +56,54 @@ const parseGraphQLSchema = ({ schemaAst, sourceMap, typeMappersMap, whitelistedM
|
|
|
44
56
|
defaultTypeMappers: {},
|
|
45
57
|
},
|
|
46
58
|
});
|
|
47
|
-
};
|
|
59
|
+
});
|
|
48
60
|
exports.parseGraphQLSchema = parseGraphQLSchema;
|
|
49
|
-
const handleScalarType = (schemaType, result) => {
|
|
50
|
-
const scalarResolver =
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
const handleScalarType = ({ scalarResolverMap, schemaType, result, scalarsModule, scalarsOverrides, }) => {
|
|
62
|
+
const scalarResolver = scalarResolverMap[schemaType];
|
|
63
|
+
// Use found the scalar from scalar module
|
|
64
|
+
if (scalarResolver) {
|
|
65
|
+
if (scalarResolver.extensions.codegenScalarType &&
|
|
66
|
+
typeof scalarResolver.extensions.codegenScalarType === 'string') {
|
|
67
|
+
result.pluginsConfig.defaultScalarTypesMap[schemaType] =
|
|
68
|
+
scalarResolver.extensions.codegenScalarType;
|
|
69
|
+
}
|
|
70
|
+
result.pluginsConfig.defaultScalarExternalResolvers[schemaType] = `~${scalarsModule}#${scalarResolver.name}Resolver`;
|
|
71
|
+
}
|
|
72
|
+
// If found scalar overrides, use them
|
|
73
|
+
const override = scalarsOverrides[schemaType];
|
|
74
|
+
if (override) {
|
|
75
|
+
if (override.type) {
|
|
76
|
+
result.pluginsConfig.defaultScalarTypesMap[schemaType] = override.type;
|
|
77
|
+
}
|
|
78
|
+
if (override.resolver) {
|
|
79
|
+
result.pluginsConfig.defaultScalarExternalResolvers[schemaType] =
|
|
80
|
+
override.resolver;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const getScalarResolverMapFromModule = (scalarsModule) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
85
|
+
let module;
|
|
86
|
+
try {
|
|
87
|
+
module = yield Promise.resolve(`${scalarsModule}`).then(s => require(s));
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
if (err instanceof Error &&
|
|
91
|
+
'code' in err &&
|
|
92
|
+
err.code === 'MODULE_NOT_FOUND') {
|
|
93
|
+
console.warn(utils_1.fmt.warn(`Unable to import \`${scalarsModule}\`. Install \`${scalarsModule}\` or you have to implement Scalar resolvers by yourself.`));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (!module || !module.resolvers) {
|
|
97
|
+
return {};
|
|
53
98
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
99
|
+
return module.resolvers;
|
|
100
|
+
});
|
|
101
|
+
const handleNativeScalarType = ({ schemaType, result, scalarsOverrides, }) => {
|
|
102
|
+
const override = scalarsOverrides[schemaType];
|
|
103
|
+
// Note: only override the type i.e. same functionality as `typescript` plugin's scalars
|
|
104
|
+
// I've never seen someone overriding native scalar's implementation so it's probably not a thing.
|
|
105
|
+
if (override && override.type) {
|
|
106
|
+
result.pluginsConfig.defaultScalarTypesMap[schemaType] = override.type;
|
|
58
107
|
}
|
|
59
|
-
result.pluginsConfig.defaultScalarExternalResolvers[schemaType] = `~graphql-scalars#${scalarResolver.name}Resolver`;
|
|
60
108
|
};
|
|
61
109
|
//# sourceMappingURL=parseGraphQLSchema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseGraphQLSchema.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/parseGraphQLSchema/parseGraphQLSchema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parseGraphQLSchema.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/parseGraphQLSchema/parseGraphQLSchema.ts"],"names":[],"mappings":";;;;AAAA,qCAMiB;AAOjB,oCAKkB;AAwBX,MAAM,kBAAkB,GAAG,CAAO,EACvC,SAAS,EACT,SAAS,EACT,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,GACO,EAAoC,EAAE;IAC/D,MAAM,iBAAiB,GAAG,aAAa;QACrC,CAAC,CAAC,MAAM,8BAA8B,CAAC,aAAa,CAAC;QACrD,CAAC,CAAC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,GAAG,CACrC,aAAqB,EACyC,EAAE;IAChE,IAAI,MAES,CAAC;IACd,IAAI;QACF,MAAM,GAAG,yBAAa,aAAa,yBAAC,CAAC;KACtC;IAAC,OAAO,GAAG,EAAE;QACZ,IACE,GAAG,YAAY,KAAK;YACpB,MAAM,IAAI,GAAG;YACb,GAAG,CAAC,IAAI,KAAK,kBAAkB,EAC/B;YACA,OAAO,CAAC,IAAI,CACV,WAAG,CAAC,IAAI,CACN,sBAAsB,aAAa,iBAAiB,aAAa,2DAA2D,CAC7H,CACF,CAAC;SACH;KACF;IAED,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;QAChC,OAAO,EAAE,CAAC;KACX;IAED,OAAO,MAAM,CAAC,SAAS,CAAC;AAC1B,CAAC,CAAA,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,EAC9B,UAAU,EACV,MAAM,EACN,gBAAgB,GAKjB,EAAQ,EAAE;IACT,MAAM,QAAQ,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC9C,wFAAwF;IACxF,kGAAkG;IAClG,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE;QAC7B,MAAM,CAAC,aAAa,CAAC,qBAAqB,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC;KACxE;AACH,CAAC,CAAC"}
|
|
@@ -58,6 +58,25 @@ const collectTypeMappersFromSourceFile = ({ typeMappersSourceFile, typeMappersSu
|
|
|
58
58
|
}, result);
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
|
+
typeMappersSourceFile.getClasses().forEach((classDeclaration) => {
|
|
62
|
+
if (!classDeclaration.hasExportKeyword()) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const identifierNode = classDeclaration.getNameNode();
|
|
66
|
+
if (!identifierNode) {
|
|
67
|
+
// Anonymous class is skipped
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
addTypeMapperDetailsIfValid({
|
|
71
|
+
declarationNode: null,
|
|
72
|
+
identifierNode,
|
|
73
|
+
typeMappersSuffix,
|
|
74
|
+
typeMappersFilePath: typeMappersSourceFile.getFilePath(),
|
|
75
|
+
resolverTypesPath,
|
|
76
|
+
shouldCollectPropertyMap,
|
|
77
|
+
emitLegacyCommonJSImports,
|
|
78
|
+
}, result);
|
|
79
|
+
});
|
|
61
80
|
};
|
|
62
81
|
exports.collectTypeMappersFromSourceFile = collectTypeMappersFromSourceFile;
|
|
63
82
|
const addTypeMapperDetailsIfValid = ({ declarationNode, identifierNode, typeMappersSuffix, typeMappersFilePath, resolverTypesPath, shouldCollectPropertyMap, emitLegacyCommonJSImports, }, result) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectTypeMappersFromSourceFile.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/parseTypeMappers/collectTypeMappersFromSourceFile.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,uCAOkB;AAClB,oCAAqE;AAG9D,MAAM,gCAAgC,GAAG,CAC9C,EACE,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,yBAAyB,GAO1B,EACD,MAAsB,EAChB,EAAE;IACR,6CAA6C;IAC7C,qBAAqB,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,CAAC,oBAAoB,EAAE,EAAE;QACrE,IAAI,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,EAAE;YAC5C,OAAO;SACR;QAED,2BAA2B,CACzB;YACE,eAAe,EAAE,oBAAoB;YACrC,cAAc,EAAE,oBAAoB,CAAC,WAAW,EAAE;YAClD,iBAAiB;YACjB,mBAAmB,EAAE,qBAAqB,CAAC,WAAW,EAAE;YACxD,iBAAiB;YACjB,wBAAwB;YACxB,yBAAyB;SAC1B,EACD,MAAM,CACP,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,iDAAiD;IACjD,qBAAqB,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC3D,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,EAAE;YACjC,OAAO;SACR;QAED,MAAM,cAAc,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;QAE/C,2BAA2B,CACzB;YACE,eAAe,EAAE,SAAS;YAC1B,cAAc;YACd,iBAAiB;YACjB,mBAAmB,EAAE,qBAAqB,CAAC,WAAW,EAAE;YACxD,iBAAiB;YACjB,wBAAwB;YACxB,yBAAyB;SAC1B,EACD,MAAM,CACP,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,8BAA8B;IAC9B,0CAA0C;IAC1C,+CAA+C;IAC/C,6DAA6D;IAE7D,qBAAqB,CAAC,qBAAqB,EAAE,CAAC,OAAO,CAAC,CAAC,iBAAiB,EAAE,EAAE;QAC1E,iBAAiB,CAAC,eAAe,EAAE,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;YAC1D,IAAI,cAAc,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;YAC/C,MAAM,SAAS,GAAG,WAAW,CAAC,YAAY,EAAE,CAAC;YAC7C,IAAI,SAAS,EAAE;gBACb,cAAc,GAAG,SAAS,CAAC;aAC5B;YAED,2BAA2B,CACzB;gBACE,eAAe,EAAE,IAAI;gBACrB,cAAc;gBACd,iBAAiB;gBACjB,mBAAmB,EAAE,qBAAqB,CAAC,WAAW,EAAE;gBACxD,iBAAiB;gBACjB,wBAAwB;gBACxB,yBAAyB;aAC1B,EACD,MAAM,CACP,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"collectTypeMappersFromSourceFile.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/parseTypeMappers/collectTypeMappersFromSourceFile.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,uCAOkB;AAClB,oCAAqE;AAG9D,MAAM,gCAAgC,GAAG,CAC9C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EAAE;IACR,IAAI,CAAC,eAAe,EAAE;QACpB,OAAO,cAAc,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,CAAC;KAC/C;IAED,uBAAuB;IACvB,IAAI,eAAe,CAAC,MAAM,CAAC,qBAAU,CAAC,oBAAoB,CAAC,EAAE;QAC3D,OAAO,eAAe,CAAC;KACxB;IAED,uBAAuB;IACvB,MAAM,QAAQ,GAAG,eAAe,CAAC,kBAAkB,EAAE,CAAC;IACtD,MAAM,IAAI,GAAG,eAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,4EAA4E;QACtH,CAAC,CAAC,cAAc,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;QACxC,CAAC,CAAC,eAAe,CAAC;IACpB,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
package/src/preset.js
CHANGED
|
@@ -8,6 +8,7 @@ const typeScriptPlugin = require("@graphql-codegen/typescript");
|
|
|
8
8
|
const typeScriptResolversPlugin = require("@graphql-codegen/typescript-resolvers");
|
|
9
9
|
const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
|
|
10
10
|
const ts_morph_1 = require("ts-morph");
|
|
11
|
+
const gcg_server_config_1 = require("@eddeee888/gcg-server-config");
|
|
11
12
|
const parseSources_1 = require("./parseSources");
|
|
12
13
|
const parseGraphQLSchema_1 = require("./parseGraphQLSchema");
|
|
13
14
|
const generateResolverFiles_1 = require("./generateResolverFiles");
|
|
@@ -16,6 +17,7 @@ const getGraphQLObjectTypeResolversToGenerate_1 = require("./getGraphQLObjectTyp
|
|
|
16
17
|
const addVirtualTypesFileToTsMorphProject_1 = require("./addVirtualTypesFileToTsMorphProject");
|
|
17
18
|
const parseTypeMappers_1 = require("./parseTypeMappers");
|
|
18
19
|
const validatePresetConfig_1 = require("./validatePresetConfig");
|
|
20
|
+
const validateAndMergeParsedConfigs_1 = require("./validateAndMergeParsedConfigs");
|
|
19
21
|
exports.presetName = '@eddeee888/gcg-typescript-resolver-files';
|
|
20
22
|
exports.preset = {
|
|
21
23
|
buildGeneratesSection: ({ schema, schemaAst, presetConfig: rawPresetConfig, baseOutputDir, profiler = (0, plugin_helpers_1.createNoopProfiler)(), }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -26,7 +28,7 @@ exports.preset = {
|
|
|
26
28
|
if (!Array.isArray(sources) || sources.length === 0) {
|
|
27
29
|
throw new Error('Empty Sources. Make sure schema files are parsed correctly.');
|
|
28
30
|
}
|
|
29
|
-
const { resolverTypesPath: relativeResolverTypesPathFromBaseOutputDir, resolverRelativeTargetDir, mappersFileExtension: typeMappersFileExtension, mappersSuffix: typeMappersSuffix, resolverMainFile, resolverMainFileMode, typeDefsFilePath, typeDefsFileMode, mode, whitelistedModules, blacklistedModules, externalResolvers, typesPluginsConfig, tsMorphProjectOptions, fixObjectTypeResolvers, emitLegacyCommonJSImports, } = (0, validatePresetConfig_1.validatePresetConfig)(rawPresetConfig);
|
|
31
|
+
const { resolverTypesPath: relativeResolverTypesPathFromBaseOutputDir, resolverRelativeTargetDir, mappersFileExtension: typeMappersFileExtension, mappersSuffix: typeMappersSuffix, resolverMainFile, resolverMainFileMode, resolverGeneration, typeDefsFilePath, typeDefsFileMode, scalarsModule, scalarsOverrides, mode, whitelistedModules, blacklistedModules, externalResolvers, typesPluginsConfig, tsMorphProjectOptions, fixObjectTypeResolvers, emitLegacyCommonJSImports, } = (0, validatePresetConfig_1.validatePresetConfig)(rawPresetConfig);
|
|
30
32
|
const resolverTypesPath = path.posix.join(baseOutputDir, relativeResolverTypesPathFromBaseOutputDir);
|
|
31
33
|
const { sourceMap } = (0, parseSources_1.parseSources)(sources);
|
|
32
34
|
const tsMorphProject = yield profiler.run(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return new ts_morph_1.Project(tsMorphProjectOptions); }), createProfilerRunName('Initialising ts-morph project'));
|
|
@@ -42,15 +44,21 @@ exports.preset = {
|
|
|
42
44
|
});
|
|
43
45
|
}), createProfilerRunName('parseTypeMappers'));
|
|
44
46
|
const generatesSection = [];
|
|
45
|
-
const
|
|
47
|
+
const parsedGraphQLSchemaMeta = yield (0, parseGraphQLSchema_1.parseGraphQLSchema)({
|
|
46
48
|
schemaAst,
|
|
47
49
|
sourceMap,
|
|
50
|
+
scalarsModule,
|
|
51
|
+
scalarsOverrides,
|
|
48
52
|
typeMappersMap,
|
|
49
53
|
whitelistedModules,
|
|
50
54
|
blacklistedModules,
|
|
51
55
|
});
|
|
56
|
+
const mergedConfig = (0, validateAndMergeParsedConfigs_1.validateAndMergeParsedConfigs)({
|
|
57
|
+
externalResolvers,
|
|
58
|
+
parsedGraphQLSchemaMeta,
|
|
59
|
+
});
|
|
52
60
|
// typescript and typescript-resolvers plugins config
|
|
53
|
-
const resolverTypesConfig = Object.assign(Object.assign({
|
|
61
|
+
const resolverTypesConfig = (0, gcg_server_config_1.defineConfig)(Object.assign(Object.assign({ emitLegacyCommonJSImports }, typesPluginsConfig), { scalars: mergedConfig.scalarTypes, mappers: Object.assign(Object.assign({}, mergedConfig.typeMappers), typesPluginsConfig.mappers) }));
|
|
54
62
|
// typesSourceFile is the virtual `types.generated.ts`
|
|
55
63
|
// This is useful when we need to do static analysis as most types come from this file
|
|
56
64
|
// e.g. comparing mappers field type vs schema object field type
|
|
@@ -63,7 +71,7 @@ exports.preset = {
|
|
|
63
71
|
const graphQLObjectTypeResolversToGenerate = yield profiler.run(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
64
72
|
return (0, getGraphQLObjectTypeResolversToGenerate_1.getGraphQLObjectTypeResolversToGenerate)({
|
|
65
73
|
typesSourceFile,
|
|
66
|
-
userDefinedSchemaObjectTypeMap: userDefinedSchemaTypeMap.object,
|
|
74
|
+
userDefinedSchemaObjectTypeMap: mergedConfig.userDefinedSchemaTypeMap.object,
|
|
67
75
|
typeMappersMap,
|
|
68
76
|
});
|
|
69
77
|
}), createProfilerRunName('graphQLObjectTypeResolversToGenerate'));
|
|
@@ -118,6 +126,7 @@ exports.preset = {
|
|
|
118
126
|
resolverRelativeTargetDir,
|
|
119
127
|
resolverMainFile,
|
|
120
128
|
resolverMainFileMode,
|
|
129
|
+
resolverGeneration,
|
|
121
130
|
graphQLObjectTypeResolversToGenerate,
|
|
122
131
|
tsMorph: {
|
|
123
132
|
project: tsMorphProject,
|
|
@@ -127,7 +136,7 @@ exports.preset = {
|
|
|
127
136
|
mode,
|
|
128
137
|
whitelistedModules,
|
|
129
138
|
blacklistedModules,
|
|
130
|
-
externalResolvers: Object.assign(
|
|
139
|
+
externalResolvers: Object.assign({}, mergedConfig.externalResolvers),
|
|
131
140
|
emitLegacyCommonJSImports,
|
|
132
141
|
},
|
|
133
142
|
result,
|
package/src/preset.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preset.js","sourceRoot":"","sources":["../../../../packages/typescript-resolver-files/src/preset.ts"],"names":[],"mappings":";;;;AAAA,6BAA6B;AAC7B,kDAAkD;AAClD,gEAAgE;AAChE,mFAAmF;AACnF,oEAGyC;AACzC,uCAAmC;AACnC,iDAA8C;AAC9C,6DAA0D;AAC1D,mEAGiC;AACjC,mEAAgE;AAChE,uGAAoG;AACpG,+FAA4F;AAC5F,yDAAsD;AACtD,iEAA+E;
|
|
1
|
+
{"version":3,"file":"preset.js","sourceRoot":"","sources":["../../../../packages/typescript-resolver-files/src/preset.ts"],"names":[],"mappings":";;;;AAAA,6BAA6B;AAC7B,kDAAkD;AAClD,gEAAgE;AAChE,mFAAmF;AACnF,oEAGyC;AACzC,uCAAmC;AACnC,oEAA4D;AAC5D,iDAA8C;AAC9C,6DAA0D;AAC1D,mEAGiC;AACjC,mEAAgE;AAChE,uGAAoG;AACpG,+FAA4F;AAC5F,yDAAsD;AACtD,iEAA+E;AAC/E,mFAAgF;AAEnE,QAAA,UAAU,GAAG,0CAA0C,CAAC;AAExD,QAAA,MAAM,GAAwC;IACzD,qBAAqB,EAAE,CAAO,EAC5B,MAAM,EACN,SAAS,EACT,YAA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IAAA,6CAAqB,EAAC;gBACpB,MAAM,EAAE;oBACN,MAAM,EAAE,SAAS;oBACjB,SAAS;oBACT,aAAa;oBACb,iBAAiB;oBACjB,yBAAyB;oBACzB,gBAAgB;oBAChB,oBAAoB;oBACpB,kBAAkB;oBAClB,oCAAoC;oBACpC,OAAO,EAAE;wBACP,OAAO,EAAE,cAAc;wBACvB,eAAe;qBAChB;oBACD,sBAAsB;oBACtB,IAAI;oBACJ,kBAAkB;oBAClB,kBAAkB;oBAClB,iBAAiB,oBACZ,YAAY,CAAC,iBAAiB,CAClC;oBACD,yBAAyB;iBAC1B;gBACD,MAAM;aACP,CAAC,CAAA;UAAA,EACJ,qBAAqB,CAAC,uBAAuB,CAAC,CAC/C,CAAC;QACF,MAAM,4BAA4B,GAChC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YAC7D,QAAQ;YACR,SAAS,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE;YAC7B,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC;YAC/B,MAAM,EAAE,EAAE;YACV,MAAM;YACN,SAAS,EAAE,EAAE;SACd,CAAC,CAAC,CAAC;QAEN,OAAO,CAAC,GAAG,4BAA4B,EAAE,GAAG,gBAAgB,CAAC,CAAC;IAChE,CAAC,CAAA;CACF,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,SAAiB,EAAU,EAAE,CAC1D,IAAI,kBAAU,MAAM,SAAS,EAAE,CAAC"}
|
|
@@ -32,6 +32,11 @@ const getNodeProperties = (node) => {
|
|
|
32
32
|
collectTypeNodeProperties(typeNode, properties);
|
|
33
33
|
return properties;
|
|
34
34
|
}
|
|
35
|
+
else if (node.isKind(ts_morph_1.SyntaxKind.ClassDeclaration)) {
|
|
36
|
+
const properties = [];
|
|
37
|
+
collectClassNodeProperties(node, properties);
|
|
38
|
+
return properties;
|
|
39
|
+
}
|
|
35
40
|
return [];
|
|
36
41
|
};
|
|
37
42
|
const collectTypeNodeProperties = (typeNode, result) => {
|
|
@@ -54,4 +59,25 @@ const collectTypeNodeProperties = (typeNode, result) => {
|
|
|
54
59
|
});
|
|
55
60
|
}
|
|
56
61
|
};
|
|
62
|
+
const collectClassNodeProperties = (classNode, result) => {
|
|
63
|
+
const baseClass = classNode.getBaseClass();
|
|
64
|
+
if (baseClass) {
|
|
65
|
+
collectClassNodeProperties(baseClass, result);
|
|
66
|
+
}
|
|
67
|
+
classNode.getInstanceProperties().forEach((prop) => {
|
|
68
|
+
if (prop.hasModifier(ts_morph_1.SyntaxKind.PrivateKeyword) ||
|
|
69
|
+
prop.hasModifier(ts_morph_1.SyntaxKind.ProtectedKeyword)) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (prop.getName().startsWith('#')) {
|
|
73
|
+
// ecma script private field is skipped
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (classNode.getGetAccessor(prop.getName())) {
|
|
77
|
+
// getter is skipped
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
result.push({ propertyName: prop.getName() });
|
|
81
|
+
});
|
|
82
|
+
};
|
|
57
83
|
//# sourceMappingURL=getNodePropertyMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNodePropertyMap.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/utils/getNodePropertyMap.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"getNodePropertyMap.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/utils/getNodePropertyMap.ts"],"names":[],"mappings":";;;AAAA,uCAA6E;AAI7E;;;GAGG;AACI,MAAM,kBAAkB,GAAG,CAAC,IAAsB,EAAmB,EAAE;IAC5E,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE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;QACD,IAAI,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE;YAC5C,oBAAoB;YACpB,OAAO;SACR;QACD,MAAM,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
export interface ImportLineMeta {
|
|
2
2
|
isTypeImport: boolean;
|
|
3
3
|
module: string;
|
|
4
|
+
/**
|
|
5
|
+
* moduleType
|
|
6
|
+
*
|
|
7
|
+
* @description Determines how the module should be treated when imported taking into consideration CJS vs ESM
|
|
8
|
+
* - file: import is a file. For ESM, .js extension is added. For CJS, no extension is added.
|
|
9
|
+
* - module: import is a module from `node_modules` or aliased e.g. `graphql-scalars` or `@org/your-module`. No extension is added.
|
|
10
|
+
* - preserve: preserve what the config declares. This is only used when taking user's config or preset-controlled config e.g. `externalExternals` because the import could be either file or module
|
|
11
|
+
*/
|
|
12
|
+
moduleType: 'file' | 'module' | 'preserve';
|
|
4
13
|
namedImports: (string | {
|
|
5
14
|
propertyName: string;
|
|
6
15
|
identifierName: string;
|
|
@@ -8,4 +17,4 @@ export interface ImportLineMeta {
|
|
|
8
17
|
defaultImport?: string;
|
|
9
18
|
emitLegacyCommonJSImports: boolean;
|
|
10
19
|
}
|
|
11
|
-
export declare function printImportLine({ isTypeImport, module, namedImports, defaultImport, emitLegacyCommonJSImports, }: ImportLineMeta): string;
|
|
20
|
+
export declare function printImportLine({ isTypeImport, module, moduleType, namedImports, defaultImport, emitLegacyCommonJSImports, }: ImportLineMeta): string;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.printImportLine = void 0;
|
|
4
|
-
function printImportLine({ isTypeImport, module, namedImports, defaultImport, emitLegacyCommonJSImports, }) {
|
|
4
|
+
function printImportLine({ isTypeImport, module, moduleType, namedImports, defaultImport, emitLegacyCommonJSImports, }) {
|
|
5
5
|
const typeImportKeyword = isTypeImport ? 'type' : '';
|
|
6
6
|
const hasDefaultImport = Boolean(defaultImport);
|
|
7
7
|
const hasNamedImports = namedImports.length > 0;
|
|
8
8
|
const namedImportsString = hasNamedImports
|
|
9
9
|
? `{ ${namedImports.map(printNamedImportSpecifier).join(',')} }`
|
|
10
10
|
: '';
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
let fileExt = '';
|
|
12
|
+
if (moduleType !== 'preserve') {
|
|
13
|
+
const isFile = moduleType === 'file';
|
|
14
|
+
fileExt = emitLegacyCommonJSImports || !isFile ? '' : '.js';
|
|
15
|
+
}
|
|
13
16
|
return `import ${typeImportKeyword} ${defaultImport || ''} ${hasDefaultImport && hasNamedImports ? ',' : ''} ${namedImportsString} from '${normalizeModuleExtensionForImport(module)}${fileExt}';`;
|
|
14
17
|
}
|
|
15
18
|
exports.printImportLine = printImportLine;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printImportLine.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/utils/printImportLine.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"printImportLine.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/utils/printImportLine.ts"],"names":[],"mappings":";;;AAiBA,SAAgB,eAAe,CAAC,EAC9B,YAAY,EACZ,MAAM,EACN,UAAU,EACV,YAAY,EACZ,aAAa,EACb,yBAAyB,GACV;IACf,MAAM,iBAAiB,GAAG,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACrD,MAAM,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAChD,MAAM,eAAe,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;IAChD,MAAM,kBAAkB,GAAG,eAAe;QACxC,CAAC,CAAC,KAAK,YAAY,CAA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|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/validateAndMergeParsedConfigs/index.ts"],"names":[],"mappings":";;;AAAA,0EAAgD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ParsedGraphQLSchemaMeta } from '../parseGraphQLSchema';
|
|
2
|
+
import type { ParsedPresetConfig, ScalarsOverridesType } from '../validatePresetConfig';
|
|
3
|
+
interface MergedConfig {
|
|
4
|
+
userDefinedSchemaTypeMap: ParsedGraphQLSchemaMeta['userDefinedSchemaTypeMap'];
|
|
5
|
+
externalResolvers: ParsedPresetConfig['externalResolvers'];
|
|
6
|
+
scalarTypes: Record<string, ScalarsOverridesType>;
|
|
7
|
+
typeMappers: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* validateAndMergeParsedConfigs is used to make sure all parsed configs do not incorrectly override each other.
|
|
11
|
+
* Use this to ensure there's only one way of doing something. e.g.
|
|
12
|
+
* - scalarsOverrides must be used over externalResolvers to override scalars
|
|
13
|
+
*/
|
|
14
|
+
export declare const validateAndMergeParsedConfigs: ({ externalResolvers, parsedGraphQLSchemaMeta: { userDefinedSchemaTypeMap, pluginsConfig: { defaultScalarExternalResolvers, defaultScalarTypesMap, defaultTypeMappers, }, }, }: {
|
|
15
|
+
externalResolvers: ParsedPresetConfig['externalResolvers'];
|
|
16
|
+
parsedGraphQLSchemaMeta: ParsedGraphQLSchemaMeta;
|
|
17
|
+
}) => MergedConfig;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateAndMergeParsedConfigs = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
/**
|
|
6
|
+
* validateAndMergeParsedConfigs is used to make sure all parsed configs do not incorrectly override each other.
|
|
7
|
+
* Use this to ensure there's only one way of doing something. e.g.
|
|
8
|
+
* - scalarsOverrides must be used over externalResolvers to override scalars
|
|
9
|
+
*/
|
|
10
|
+
const validateAndMergeParsedConfigs = ({ externalResolvers, parsedGraphQLSchemaMeta: { userDefinedSchemaTypeMap, pluginsConfig: { defaultScalarExternalResolvers, defaultScalarTypesMap, defaultTypeMappers, }, }, }) => {
|
|
11
|
+
Object.keys(externalResolvers).forEach((schemaType) => {
|
|
12
|
+
if (userDefinedSchemaTypeMap.scalar[schemaType]) {
|
|
13
|
+
throw new Error(utils_1.fmt.error(`Scalar "${schemaType}" found in presetConfig.externalResolvers. Use presetConfig.scalarsOverrides to override scalar implementation and type. Remove "${schemaType}" from presetConfig.externalResolvers.`, 'Validation'));
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
userDefinedSchemaTypeMap,
|
|
18
|
+
externalResolvers: Object.assign(Object.assign({}, defaultScalarExternalResolvers), externalResolvers),
|
|
19
|
+
scalarTypes: Object.assign({}, defaultScalarTypesMap),
|
|
20
|
+
typeMappers: defaultTypeMappers,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
exports.validateAndMergeParsedConfigs = validateAndMergeParsedConfigs;
|
|
24
|
+
//# sourceMappingURL=validateAndMergeParsedConfigs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateAndMergeParsedConfigs.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/validateAndMergeParsedConfigs/validateAndMergeParsedConfigs.ts"],"names":[],"mappings":";;;AAKA,oCAA+B;AAS/B;;;;GAIG;AACI,MAAM,6BAA6B,GAAG,CAAC,EAC5C,iBAAiB,EACjB,uBAAuB,EAAE,EACvB,wBAAwB,EACxB,aAAa,EAAE,EACb,8BAA8B,EAC9B,qBAAqB,EACrB,kBAAkB,GACnB,GACF,GAIF,EAAgB,EAAE;IACjB,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;QACpD,IAAI,wBAAwB,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;YAC/C,MAAM,IAAI,KAAK,CACb,WAAG,CAAC,KAAK,CACP,WAAW,UAAU,oIAAoI,UAAU,wCAAwC,EAC3M,YAAY,CACb,CACF,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,wBAAwB;QACxB,iBAAiB,kCACZ,8BAA8B,GAC9B,iBAAiB,CACrB;QACD,WAAW,oBACN,qBAAqB,CACzB;QACD,WAAW,EAAE,kBAAkB;KAChC,CAAC;AACJ,CAAC,CAAC;AApCW,QAAA,6BAA6B,iCAoCxC"}
|
|
@@ -1,22 +1,39 @@
|
|
|
1
1
|
import * as typeScriptPlugin from '@graphql-codegen/typescript';
|
|
2
2
|
import * as typeScriptResolversPlugin from '@graphql-codegen/typescript-resolvers';
|
|
3
3
|
import type { ProjectOptions } from 'ts-morph';
|
|
4
|
-
type ParsedTypesPluginsConfig = Omit<typeScriptPlugin.TypeScriptPluginConfig
|
|
5
|
-
scalars: Record<string, string>;
|
|
6
|
-
};
|
|
4
|
+
type ParsedTypesPluginsConfig = Omit<typeScriptPlugin.TypeScriptPluginConfig & typeScriptResolversPlugin.TypeScriptResolversPluginConfig, 'scalars' | 'emitLegacyCommonJSImports'>;
|
|
7
5
|
type ConfigMode = 'merged' | 'modules';
|
|
8
6
|
type ResolverMainFileMode = 'merged' | 'modules';
|
|
9
7
|
export type TypeDefsFileMode = 'merged' | 'mergedWhitelisted' | 'modules';
|
|
10
8
|
type FixObjectTypeResolvers = 'smart' | 'disabled';
|
|
9
|
+
type ResolverGeneration = 'disabled' | 'recommended' | 'all';
|
|
10
|
+
export type ScalarsOverridesType = string | {
|
|
11
|
+
input: string;
|
|
12
|
+
output: string;
|
|
13
|
+
};
|
|
11
14
|
export interface ParsedPresetConfig {
|
|
12
15
|
resolverTypesPath: string;
|
|
13
16
|
resolverRelativeTargetDir: string;
|
|
14
17
|
resolverMainFile: string;
|
|
15
18
|
resolverMainFileMode: ResolverMainFileMode;
|
|
19
|
+
resolverGeneration: {
|
|
20
|
+
query: boolean;
|
|
21
|
+
mutation: boolean;
|
|
22
|
+
subscription: boolean;
|
|
23
|
+
scalar: boolean;
|
|
24
|
+
object: boolean;
|
|
25
|
+
union: boolean;
|
|
26
|
+
interface: boolean;
|
|
27
|
+
};
|
|
16
28
|
typeDefsFilePath: string | false;
|
|
17
29
|
typeDefsFileMode: TypeDefsFileMode;
|
|
18
30
|
mappersFileExtension: string;
|
|
19
31
|
mappersSuffix: string;
|
|
32
|
+
scalarsModule: string | false;
|
|
33
|
+
scalarsOverrides: Record<string, {
|
|
34
|
+
resolver?: string;
|
|
35
|
+
type?: ScalarsOverridesType;
|
|
36
|
+
}>;
|
|
20
37
|
mode: ConfigMode;
|
|
21
38
|
whitelistedModules: string[];
|
|
22
39
|
blacklistedModules: string[];
|
|
@@ -31,10 +48,16 @@ export interface RawPresetConfig {
|
|
|
31
48
|
resolverRelativeTargetDir?: string;
|
|
32
49
|
resolverMainFile?: string;
|
|
33
50
|
resolverMainFileMode?: string;
|
|
51
|
+
resolverGeneration?: string;
|
|
34
52
|
typeDefsFilePath?: string | boolean;
|
|
35
53
|
typeDefsFileMode?: string;
|
|
36
54
|
mappersFileExtension?: string;
|
|
37
55
|
mappersSuffix?: string;
|
|
56
|
+
scalarsModule?: string | boolean;
|
|
57
|
+
scalarsOverrides?: Record<string, {
|
|
58
|
+
resolver?: string;
|
|
59
|
+
type?: ScalarsOverridesType;
|
|
60
|
+
}>;
|
|
38
61
|
mode?: string;
|
|
39
62
|
whitelistedModules?: string[];
|
|
40
63
|
blacklistedModules?: string[];
|
|
@@ -49,6 +72,8 @@ export interface TypedPresetConfig extends RawPresetConfig {
|
|
|
49
72
|
resolverMainFileMode?: ResolverMainFileMode;
|
|
50
73
|
typeDefsFileMode?: TypeDefsFileMode;
|
|
51
74
|
fixObjectTypeResolvers?: FixObjectTypeResolvers;
|
|
75
|
+
typesPluginsConfig?: ParsedTypesPluginsConfig;
|
|
76
|
+
resolverGeneration?: ResolverGeneration;
|
|
52
77
|
}
|
|
53
|
-
export declare const validatePresetConfig: ({ resolverTypesPath, resolverRelativeTargetDir, resolverMainFile, resolverMainFileMode, typeDefsFilePath, typeDefsFileMode: inputTypeDefsFileMode, mappersFileExtension, mappersSuffix, mode, whitelistedModules, blacklistedModules, externalResolvers, typesPluginsConfig, tsConfigFilePath, fixObjectTypeResolvers, emitLegacyCommonJSImports, }: RawPresetConfig) => ParsedPresetConfig;
|
|
78
|
+
export declare const validatePresetConfig: ({ resolverTypesPath, resolverRelativeTargetDir, resolverMainFile, resolverMainFileMode, resolverGeneration, typeDefsFilePath, typeDefsFileMode: inputTypeDefsFileMode, mappersFileExtension, mappersSuffix, scalarsModule, scalarsOverrides, mode, whitelistedModules, blacklistedModules, externalResolvers, typesPluginsConfig, tsConfigFilePath, fixObjectTypeResolvers, emitLegacyCommonJSImports, }: RawPresetConfig) => ParsedPresetConfig;
|
|
54
79
|
export {};
|