@baeta/plugin-graphql 0.0.5 → 0.0.7
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/CHANGELOG.md +11 -0
- package/index.cjs +32 -57
- package/index.js +39 -67
- package/package.json +23 -8
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @baeta/plugin-graphql
|
|
2
|
+
|
|
3
|
+
## 0.0.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ffa2fe8`](https://github.com/andreisergiu98/baeta/commit/ffa2fe83df6798375252a01ad14bbd37ffd07d50) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - add repository information to package.json
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`ffa2fe8`](https://github.com/andreisergiu98/baeta/commit/ffa2fe83df6798375252a01ad14bbd37ffd07d50)]:
|
|
10
|
+
- @baeta/core@0.0.12
|
|
11
|
+
- @baeta/plugin@0.0.5
|
package/index.cjs
CHANGED
|
@@ -32,13 +32,21 @@ module.exports = __toCommonJS(graphql_exports);
|
|
|
32
32
|
var import_plugin2 = require("@baeta/plugin");
|
|
33
33
|
|
|
34
34
|
// codegen.ts
|
|
35
|
+
var import_plugin = require("@baeta/plugin");
|
|
35
36
|
var import_core = require("@graphql-codegen/core");
|
|
36
37
|
var import_plugin_helpers4 = require("@graphql-codegen/plugin-helpers");
|
|
38
|
+
var typescriptPlugin = __toESM(require("@graphql-codegen/typescript"), 1);
|
|
39
|
+
var import_path2 = __toESM(require("path"), 1);
|
|
37
40
|
|
|
38
41
|
// modules/index.ts
|
|
42
|
+
var import_visitor_plugin_common = require("@graphql-codegen/visitor-plugin-common");
|
|
39
43
|
var import_graphql3 = require("graphql");
|
|
40
44
|
var import_path = require("path");
|
|
41
45
|
|
|
46
|
+
// modules/builder.ts
|
|
47
|
+
var import_change_case_all = require("change-case-all");
|
|
48
|
+
var import_graphql2 = require("graphql");
|
|
49
|
+
|
|
42
50
|
// modules/utils.ts
|
|
43
51
|
var import_graphql = require("graphql");
|
|
44
52
|
var import_parse_filepath = __toESM(require("parse-filepath"), 1);
|
|
@@ -120,10 +128,7 @@ function indent(size) {
|
|
|
120
128
|
}
|
|
121
129
|
return indentInner;
|
|
122
130
|
}
|
|
123
|
-
function buildBlock({
|
|
124
|
-
name,
|
|
125
|
-
lines
|
|
126
|
-
}) {
|
|
131
|
+
function buildBlock({ name, lines }) {
|
|
127
132
|
if (!lines.length) {
|
|
128
133
|
return "";
|
|
129
134
|
}
|
|
@@ -192,8 +197,6 @@ function createObject(keys, valueFn) {
|
|
|
192
197
|
}
|
|
193
198
|
|
|
194
199
|
// modules/builder.ts
|
|
195
|
-
var import_graphql2 = require("graphql");
|
|
196
|
-
var import_change_case_all = require("change-case-all");
|
|
197
200
|
var registryKeys = [
|
|
198
201
|
"objects",
|
|
199
202
|
"inputs",
|
|
@@ -202,7 +205,11 @@ var registryKeys = [
|
|
|
202
205
|
"unions",
|
|
203
206
|
"enums"
|
|
204
207
|
];
|
|
205
|
-
var resolverKeys = [
|
|
208
|
+
var resolverKeys = [
|
|
209
|
+
"scalars",
|
|
210
|
+
"objects",
|
|
211
|
+
"enums"
|
|
212
|
+
];
|
|
206
213
|
function buildModule(name, doc, {
|
|
207
214
|
importNamespace,
|
|
208
215
|
importPath,
|
|
@@ -459,9 +466,7 @@ ${body}
|
|
|
459
466
|
} else {
|
|
460
467
|
const fieldModifier = requireRootResolvers && rootTypes.includes(typeName) ? "" : "?";
|
|
461
468
|
lines.push(
|
|
462
|
-
`${typeName}${fieldModifier}: ${encapsulateTypeName(
|
|
463
|
-
typeName
|
|
464
|
-
)}Resolvers;`
|
|
469
|
+
`${typeName}${fieldModifier}: ${encapsulateTypeName(typeName)}Resolvers;`
|
|
465
470
|
);
|
|
466
471
|
}
|
|
467
472
|
});
|
|
@@ -473,12 +478,9 @@ ${body}
|
|
|
473
478
|
});
|
|
474
479
|
}
|
|
475
480
|
function printResolverType(typeName, picksTypeName, requireFieldsResolvers = false, extraKeys = "") {
|
|
476
|
-
const typeSignature = `Pick<${importNamespace}.${baseVisitor.convertName(
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
suffix: "Resolvers"
|
|
480
|
-
}
|
|
481
|
-
)}, ${picksTypeName}['${typeName}']${extraKeys}>`;
|
|
481
|
+
const typeSignature = `Pick<${importNamespace}.${baseVisitor.convertName(typeName, {
|
|
482
|
+
suffix: "Resolvers"
|
|
483
|
+
})}, ${picksTypeName}['${typeName}']${extraKeys}>`;
|
|
482
484
|
return `export type ${encapsulateTypeName(`${typeName}Resolvers`)} = ${requireFieldsResolvers ? `Required<${typeSignature}>` : typeSignature};`;
|
|
483
485
|
}
|
|
484
486
|
function printPicks(typeName, records) {
|
|
@@ -510,9 +512,7 @@ ${body}
|
|
|
510
512
|
return coreType;
|
|
511
513
|
}
|
|
512
514
|
function printExportType(typeName) {
|
|
513
|
-
return `export type ${encapsulateTypeName(typeName)} = ${printTypeBody(
|
|
514
|
-
typeName
|
|
515
|
-
)};`;
|
|
515
|
+
return `export type ${encapsulateTypeName(typeName)} = ${printTypeBody(typeName)};`;
|
|
516
516
|
}
|
|
517
517
|
function collectFields(node, picksObj) {
|
|
518
518
|
const name2 = node.name.value;
|
|
@@ -605,7 +605,6 @@ ${body}
|
|
|
605
605
|
}
|
|
606
606
|
|
|
607
607
|
// modules/index.ts
|
|
608
|
-
var import_visitor_plugin_common = require("@graphql-codegen/visitor-plugin-common");
|
|
609
608
|
var preset = {
|
|
610
609
|
buildGeneratesSection: (options) => {
|
|
611
610
|
const { baseOutputDir } = options;
|
|
@@ -675,9 +674,7 @@ var preset = {
|
|
|
675
674
|
const relativePath = (0, import_path.relative)(dirpath, baseTypesDir);
|
|
676
675
|
const importPath = options.presetConfig.importBaseTypesFrom || normalize((0, import_path.join)(relativePath, baseTypesFilename));
|
|
677
676
|
const sources = sourcesByModuleMap[moduleName];
|
|
678
|
-
const documents = sources.map(
|
|
679
|
-
(source) => source.document
|
|
680
|
-
);
|
|
677
|
+
const documents = sources.map((source) => source.document);
|
|
681
678
|
const moduleDocument = (0, import_graphql3.concatAST)(documents);
|
|
682
679
|
const shouldDeclare = filename.endsWith(".d.ts");
|
|
683
680
|
return {
|
|
@@ -721,21 +718,18 @@ var preset = {
|
|
|
721
718
|
}
|
|
722
719
|
};
|
|
723
720
|
|
|
724
|
-
// codegen.ts
|
|
725
|
-
var typescriptPlugin = __toESM(require("@graphql-codegen/typescript"), 1);
|
|
726
|
-
|
|
727
721
|
// resolvers/index.ts
|
|
728
722
|
var resolvers_exports = {};
|
|
729
723
|
__export(resolvers_exports, {
|
|
730
724
|
plugin: () => plugin
|
|
731
725
|
});
|
|
732
|
-
var import_visitor_plugin_common3 = require("@graphql-codegen/visitor-plugin-common");
|
|
733
726
|
var import_plugin_helpers = require("@graphql-codegen/plugin-helpers");
|
|
727
|
+
var import_visitor_plugin_common3 = require("@graphql-codegen/visitor-plugin-common");
|
|
734
728
|
|
|
735
729
|
// resolvers/visitor.ts
|
|
736
|
-
var import_auto_bind = __toESM(require("auto-bind"), 1);
|
|
737
|
-
var import_visitor_plugin_common2 = require("@graphql-codegen/visitor-plugin-common");
|
|
738
730
|
var import_typescript = require("@graphql-codegen/typescript");
|
|
731
|
+
var import_visitor_plugin_common2 = require("@graphql-codegen/visitor-plugin-common");
|
|
732
|
+
var import_auto_bind = __toESM(require("auto-bind"), 1);
|
|
739
733
|
var ENUM_RESOLVERS_SIGNATURE = "export type EnumResolverSignature<T, AllowedValues = any> = { [key in keyof T]?: AllowedValues };";
|
|
740
734
|
var TypeScriptResolversVisitor = class extends import_visitor_plugin_common2.BaseResolversVisitor {
|
|
741
735
|
constructor(pluginConfig, schema) {
|
|
@@ -743,22 +737,13 @@ var TypeScriptResolversVisitor = class extends import_visitor_plugin_common2.Bas
|
|
|
743
737
|
pluginConfig,
|
|
744
738
|
{
|
|
745
739
|
avoidOptionals: (0, import_visitor_plugin_common2.getConfigValue)(pluginConfig.avoidOptionals, false),
|
|
746
|
-
useIndexSignature: (0, import_visitor_plugin_common2.getConfigValue)(
|
|
747
|
-
|
|
748
|
-
false
|
|
749
|
-
),
|
|
750
|
-
wrapFieldDefinitions: (0, import_visitor_plugin_common2.getConfigValue)(
|
|
751
|
-
pluginConfig.wrapFieldDefinitions,
|
|
752
|
-
false
|
|
753
|
-
),
|
|
740
|
+
useIndexSignature: (0, import_visitor_plugin_common2.getConfigValue)(pluginConfig.useIndexSignature, false),
|
|
741
|
+
wrapFieldDefinitions: (0, import_visitor_plugin_common2.getConfigValue)(pluginConfig.wrapFieldDefinitions, false),
|
|
754
742
|
allowParentTypeOverride: (0, import_visitor_plugin_common2.getConfigValue)(
|
|
755
743
|
pluginConfig.allowParentTypeOverride,
|
|
756
744
|
false
|
|
757
745
|
),
|
|
758
|
-
optionalInfoArgument: (0, import_visitor_plugin_common2.getConfigValue)(
|
|
759
|
-
pluginConfig.optionalInfoArgument,
|
|
760
|
-
false
|
|
761
|
-
)
|
|
746
|
+
optionalInfoArgument: (0, import_visitor_plugin_common2.getConfigValue)(pluginConfig.optionalInfoArgument, false)
|
|
762
747
|
},
|
|
763
748
|
schema
|
|
764
749
|
);
|
|
@@ -872,9 +857,7 @@ export type Resolver${capitalizedDirectiveName}WithResolve<TResult, TParent, TCo
|
|
|
872
857
|
const resolverType2 = `export type ${resolverTypeName}<TResult, TParent = {}, TContext = {}, TArgs = {}> =`;
|
|
873
858
|
if (parsedMapper.isExternal) {
|
|
874
859
|
if (parsedMapper.default) {
|
|
875
|
-
prepend.push(
|
|
876
|
-
`${importType} ${resolverFnName} from '${parsedMapper.source}';`
|
|
877
|
-
);
|
|
860
|
+
prepend.push(`${importType} ${resolverFnName} from '${parsedMapper.source}';`);
|
|
878
861
|
} else {
|
|
879
862
|
prepend.push(
|
|
880
863
|
`${importType} { ${parsedMapper.import} ${parsedMapper.import !== resolverFnName ? `as ${resolverFnName} ` : ""}} from '${parsedMapper.source}';`
|
|
@@ -976,9 +959,7 @@ export type ResolverWithResolve<TResult, TParent, TContext, TArgs> = {
|
|
|
976
959
|
`${importType} { ${parsedMapper.import} ${parsedMapper.import !== "ResolverFn" ? "as ResolverFn " : ""}} from '${parsedMapper.source}';`
|
|
977
960
|
);
|
|
978
961
|
}
|
|
979
|
-
prepend.push(
|
|
980
|
-
`export${config.useTypeImports ? " type" : ""} { ResolverFn };`
|
|
981
|
-
);
|
|
962
|
+
prepend.push(`export${config.useTypeImports ? " type" : ""} { ResolverFn };`);
|
|
982
963
|
} else {
|
|
983
964
|
prepend.push(
|
|
984
965
|
`export type ResolverFn<TResult, TParent, TContext, TArgs> = ${parsedMapper.type}`
|
|
@@ -998,9 +979,7 @@ export type ResolverFn<TResult, TParent, TContext, TArgs> = (
|
|
|
998
979
|
const parsedMapper = (0, import_visitor_plugin_common3.parseMapper)(config.customSubscriptionResolver);
|
|
999
980
|
if (parsedMapper.isExternal) {
|
|
1000
981
|
if (parsedMapper.default) {
|
|
1001
|
-
prepend.push(
|
|
1002
|
-
`${importType} SubscriptionResolver from '${parsedMapper.source}';`
|
|
1003
|
-
);
|
|
982
|
+
prepend.push(`${importType} SubscriptionResolver from '${parsedMapper.source}';`);
|
|
1004
983
|
} else {
|
|
1005
984
|
prepend.push(
|
|
1006
985
|
`${importType} { ${parsedMapper.import} ${parsedMapper.import !== "SubscriptionResolver" ? "as SubscriptionResolver " : ""}} from '${parsedMapper.source}';`
|
|
@@ -1119,9 +1098,6 @@ export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs
|
|
|
1119
1098
|
};
|
|
1120
1099
|
};
|
|
1121
1100
|
|
|
1122
|
-
// codegen.ts
|
|
1123
|
-
var import_path2 = __toESM(require("path"), 1);
|
|
1124
|
-
|
|
1125
1101
|
// utils/cache.ts
|
|
1126
1102
|
function createCache() {
|
|
1127
1103
|
const cache = /* @__PURE__ */ new Map();
|
|
@@ -1139,15 +1115,15 @@ function createCache() {
|
|
|
1139
1115
|
|
|
1140
1116
|
// utils/load.ts
|
|
1141
1117
|
var import_plugin_helpers3 = require("@graphql-codegen/plugin-helpers");
|
|
1142
|
-
var
|
|
1118
|
+
var import_apollo_engine_loader = require("@graphql-tools/apollo-engine-loader");
|
|
1143
1119
|
var import_code_file_loader = require("@graphql-tools/code-file-loader");
|
|
1144
1120
|
var import_git_loader = require("@graphql-tools/git-loader");
|
|
1145
1121
|
var import_github_loader = require("@graphql-tools/github-loader");
|
|
1146
1122
|
var import_graphql_file_loader = require("@graphql-tools/graphql-file-loader");
|
|
1147
1123
|
var import_json_file_loader = require("@graphql-tools/json-file-loader");
|
|
1148
|
-
var
|
|
1149
|
-
var import_apollo_engine_loader = require("@graphql-tools/apollo-engine-loader");
|
|
1124
|
+
var import_load = require("@graphql-tools/load");
|
|
1150
1125
|
var import_prisma_loader = require("@graphql-tools/prisma-loader");
|
|
1126
|
+
var import_url_loader = require("@graphql-tools/url-loader");
|
|
1151
1127
|
|
|
1152
1128
|
// utils/hash.ts
|
|
1153
1129
|
var import_plugin_helpers2 = require("@graphql-codegen/plugin-helpers");
|
|
@@ -1187,7 +1163,6 @@ async function loadSchema(schemaPointerMap, cwd) {
|
|
|
1187
1163
|
}
|
|
1188
1164
|
|
|
1189
1165
|
// codegen.ts
|
|
1190
|
-
var import_plugin = require("@baeta/plugin");
|
|
1191
1166
|
async function generate(options) {
|
|
1192
1167
|
const root = process.cwd();
|
|
1193
1168
|
const modulesDir = import_path2.default.relative(root, options.modulesDir || "modules");
|
package/index.js
CHANGED
|
@@ -8,15 +8,27 @@ var __export = (target, all) => {
|
|
|
8
8
|
import { createPluginFactoryV1 } from "@baeta/plugin";
|
|
9
9
|
|
|
10
10
|
// codegen.ts
|
|
11
|
+
import { File } from "@baeta/plugin";
|
|
11
12
|
import { codegen as gqlCodegen } from "@graphql-codegen/core";
|
|
12
13
|
import {
|
|
13
14
|
normalizeConfig,
|
|
14
15
|
normalizeInstanceOrArray
|
|
15
16
|
} from "@graphql-codegen/plugin-helpers";
|
|
17
|
+
import * as typescriptPlugin from "@graphql-codegen/typescript";
|
|
18
|
+
import path from "path";
|
|
16
19
|
|
|
17
20
|
// modules/index.ts
|
|
21
|
+
import { BaseVisitor, getConfigValue } from "@graphql-codegen/visitor-plugin-common";
|
|
18
22
|
import { concatAST, isScalarType as isScalarType2 } from "graphql";
|
|
19
|
-
import {
|
|
23
|
+
import { join, relative, resolve } from "path";
|
|
24
|
+
|
|
25
|
+
// modules/builder.ts
|
|
26
|
+
import { pascalCase } from "change-case-all";
|
|
27
|
+
import {
|
|
28
|
+
isScalarType,
|
|
29
|
+
Kind as Kind2,
|
|
30
|
+
visit
|
|
31
|
+
} from "graphql";
|
|
20
32
|
|
|
21
33
|
// modules/utils.ts
|
|
22
34
|
import {
|
|
@@ -101,10 +113,7 @@ function indent(size) {
|
|
|
101
113
|
}
|
|
102
114
|
return indentInner;
|
|
103
115
|
}
|
|
104
|
-
function buildBlock({
|
|
105
|
-
name,
|
|
106
|
-
lines
|
|
107
|
-
}) {
|
|
116
|
+
function buildBlock({ name, lines }) {
|
|
108
117
|
if (!lines.length) {
|
|
109
118
|
return "";
|
|
110
119
|
}
|
|
@@ -173,12 +182,6 @@ function createObject(keys, valueFn) {
|
|
|
173
182
|
}
|
|
174
183
|
|
|
175
184
|
// modules/builder.ts
|
|
176
|
-
import {
|
|
177
|
-
visit,
|
|
178
|
-
Kind as Kind2,
|
|
179
|
-
isScalarType
|
|
180
|
-
} from "graphql";
|
|
181
|
-
import { pascalCase } from "change-case-all";
|
|
182
185
|
var registryKeys = [
|
|
183
186
|
"objects",
|
|
184
187
|
"inputs",
|
|
@@ -187,7 +190,11 @@ var registryKeys = [
|
|
|
187
190
|
"unions",
|
|
188
191
|
"enums"
|
|
189
192
|
];
|
|
190
|
-
var resolverKeys = [
|
|
193
|
+
var resolverKeys = [
|
|
194
|
+
"scalars",
|
|
195
|
+
"objects",
|
|
196
|
+
"enums"
|
|
197
|
+
];
|
|
191
198
|
function buildModule(name, doc, {
|
|
192
199
|
importNamespace,
|
|
193
200
|
importPath,
|
|
@@ -444,9 +451,7 @@ ${body}
|
|
|
444
451
|
} else {
|
|
445
452
|
const fieldModifier = requireRootResolvers && rootTypes.includes(typeName) ? "" : "?";
|
|
446
453
|
lines.push(
|
|
447
|
-
`${typeName}${fieldModifier}: ${encapsulateTypeName(
|
|
448
|
-
typeName
|
|
449
|
-
)}Resolvers;`
|
|
454
|
+
`${typeName}${fieldModifier}: ${encapsulateTypeName(typeName)}Resolvers;`
|
|
450
455
|
);
|
|
451
456
|
}
|
|
452
457
|
});
|
|
@@ -458,12 +463,9 @@ ${body}
|
|
|
458
463
|
});
|
|
459
464
|
}
|
|
460
465
|
function printResolverType(typeName, picksTypeName, requireFieldsResolvers = false, extraKeys = "") {
|
|
461
|
-
const typeSignature = `Pick<${importNamespace}.${baseVisitor.convertName(
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
suffix: "Resolvers"
|
|
465
|
-
}
|
|
466
|
-
)}, ${picksTypeName}['${typeName}']${extraKeys}>`;
|
|
466
|
+
const typeSignature = `Pick<${importNamespace}.${baseVisitor.convertName(typeName, {
|
|
467
|
+
suffix: "Resolvers"
|
|
468
|
+
})}, ${picksTypeName}['${typeName}']${extraKeys}>`;
|
|
467
469
|
return `export type ${encapsulateTypeName(`${typeName}Resolvers`)} = ${requireFieldsResolvers ? `Required<${typeSignature}>` : typeSignature};`;
|
|
468
470
|
}
|
|
469
471
|
function printPicks(typeName, records) {
|
|
@@ -495,9 +497,7 @@ ${body}
|
|
|
495
497
|
return coreType;
|
|
496
498
|
}
|
|
497
499
|
function printExportType(typeName) {
|
|
498
|
-
return `export type ${encapsulateTypeName(typeName)} = ${printTypeBody(
|
|
499
|
-
typeName
|
|
500
|
-
)};`;
|
|
500
|
+
return `export type ${encapsulateTypeName(typeName)} = ${printTypeBody(typeName)};`;
|
|
501
501
|
}
|
|
502
502
|
function collectFields(node, picksObj) {
|
|
503
503
|
const name2 = node.name.value;
|
|
@@ -590,10 +590,6 @@ ${body}
|
|
|
590
590
|
}
|
|
591
591
|
|
|
592
592
|
// modules/index.ts
|
|
593
|
-
import {
|
|
594
|
-
BaseVisitor,
|
|
595
|
-
getConfigValue
|
|
596
|
-
} from "@graphql-codegen/visitor-plugin-common";
|
|
597
593
|
var preset = {
|
|
598
594
|
buildGeneratesSection: (options) => {
|
|
599
595
|
const { baseOutputDir } = options;
|
|
@@ -663,9 +659,7 @@ var preset = {
|
|
|
663
659
|
const relativePath = relative(dirpath, baseTypesDir);
|
|
664
660
|
const importPath = options.presetConfig.importBaseTypesFrom || normalize(join(relativePath, baseTypesFilename));
|
|
665
661
|
const sources = sourcesByModuleMap[moduleName];
|
|
666
|
-
const documents = sources.map(
|
|
667
|
-
(source) => source.document
|
|
668
|
-
);
|
|
662
|
+
const documents = sources.map((source) => source.document);
|
|
669
663
|
const moduleDocument = concatAST(documents);
|
|
670
664
|
const shouldDeclare = filename.endsWith(".d.ts");
|
|
671
665
|
return {
|
|
@@ -709,28 +703,25 @@ var preset = {
|
|
|
709
703
|
}
|
|
710
704
|
};
|
|
711
705
|
|
|
712
|
-
// codegen.ts
|
|
713
|
-
import * as typescriptPlugin from "@graphql-codegen/typescript";
|
|
714
|
-
|
|
715
706
|
// resolvers/index.ts
|
|
716
707
|
var resolvers_exports = {};
|
|
717
708
|
__export(resolvers_exports, {
|
|
718
709
|
plugin: () => plugin
|
|
719
710
|
});
|
|
720
|
-
import { parseMapper } from "@graphql-codegen/visitor-plugin-common";
|
|
721
711
|
import {
|
|
722
712
|
addFederationReferencesToSchema,
|
|
723
713
|
getCachedDocumentNodeFromSchema,
|
|
724
714
|
oldVisit
|
|
725
715
|
} from "@graphql-codegen/plugin-helpers";
|
|
716
|
+
import { parseMapper } from "@graphql-codegen/visitor-plugin-common";
|
|
726
717
|
|
|
727
718
|
// resolvers/visitor.ts
|
|
728
|
-
import
|
|
719
|
+
import { TypeScriptOperationVariablesToObject } from "@graphql-codegen/typescript";
|
|
729
720
|
import {
|
|
730
721
|
BaseResolversVisitor,
|
|
731
722
|
getConfigValue as getConfigValue2
|
|
732
723
|
} from "@graphql-codegen/visitor-plugin-common";
|
|
733
|
-
import
|
|
724
|
+
import autoBind from "auto-bind";
|
|
734
725
|
var ENUM_RESOLVERS_SIGNATURE = "export type EnumResolverSignature<T, AllowedValues = any> = { [key in keyof T]?: AllowedValues };";
|
|
735
726
|
var TypeScriptResolversVisitor = class extends BaseResolversVisitor {
|
|
736
727
|
constructor(pluginConfig, schema) {
|
|
@@ -738,22 +729,13 @@ var TypeScriptResolversVisitor = class extends BaseResolversVisitor {
|
|
|
738
729
|
pluginConfig,
|
|
739
730
|
{
|
|
740
731
|
avoidOptionals: getConfigValue2(pluginConfig.avoidOptionals, false),
|
|
741
|
-
useIndexSignature: getConfigValue2(
|
|
742
|
-
|
|
743
|
-
false
|
|
744
|
-
),
|
|
745
|
-
wrapFieldDefinitions: getConfigValue2(
|
|
746
|
-
pluginConfig.wrapFieldDefinitions,
|
|
747
|
-
false
|
|
748
|
-
),
|
|
732
|
+
useIndexSignature: getConfigValue2(pluginConfig.useIndexSignature, false),
|
|
733
|
+
wrapFieldDefinitions: getConfigValue2(pluginConfig.wrapFieldDefinitions, false),
|
|
749
734
|
allowParentTypeOverride: getConfigValue2(
|
|
750
735
|
pluginConfig.allowParentTypeOverride,
|
|
751
736
|
false
|
|
752
737
|
),
|
|
753
|
-
optionalInfoArgument: getConfigValue2(
|
|
754
|
-
pluginConfig.optionalInfoArgument,
|
|
755
|
-
false
|
|
756
|
-
)
|
|
738
|
+
optionalInfoArgument: getConfigValue2(pluginConfig.optionalInfoArgument, false)
|
|
757
739
|
},
|
|
758
740
|
schema
|
|
759
741
|
);
|
|
@@ -867,9 +849,7 @@ export type Resolver${capitalizedDirectiveName}WithResolve<TResult, TParent, TCo
|
|
|
867
849
|
const resolverType2 = `export type ${resolverTypeName}<TResult, TParent = {}, TContext = {}, TArgs = {}> =`;
|
|
868
850
|
if (parsedMapper.isExternal) {
|
|
869
851
|
if (parsedMapper.default) {
|
|
870
|
-
prepend.push(
|
|
871
|
-
`${importType} ${resolverFnName} from '${parsedMapper.source}';`
|
|
872
|
-
);
|
|
852
|
+
prepend.push(`${importType} ${resolverFnName} from '${parsedMapper.source}';`);
|
|
873
853
|
} else {
|
|
874
854
|
prepend.push(
|
|
875
855
|
`${importType} { ${parsedMapper.import} ${parsedMapper.import !== resolverFnName ? `as ${resolverFnName} ` : ""}} from '${parsedMapper.source}';`
|
|
@@ -971,9 +951,7 @@ export type ResolverWithResolve<TResult, TParent, TContext, TArgs> = {
|
|
|
971
951
|
`${importType} { ${parsedMapper.import} ${parsedMapper.import !== "ResolverFn" ? "as ResolverFn " : ""}} from '${parsedMapper.source}';`
|
|
972
952
|
);
|
|
973
953
|
}
|
|
974
|
-
prepend.push(
|
|
975
|
-
`export${config.useTypeImports ? " type" : ""} { ResolverFn };`
|
|
976
|
-
);
|
|
954
|
+
prepend.push(`export${config.useTypeImports ? " type" : ""} { ResolverFn };`);
|
|
977
955
|
} else {
|
|
978
956
|
prepend.push(
|
|
979
957
|
`export type ResolverFn<TResult, TParent, TContext, TArgs> = ${parsedMapper.type}`
|
|
@@ -993,9 +971,7 @@ export type ResolverFn<TResult, TParent, TContext, TArgs> = (
|
|
|
993
971
|
const parsedMapper = parseMapper(config.customSubscriptionResolver);
|
|
994
972
|
if (parsedMapper.isExternal) {
|
|
995
973
|
if (parsedMapper.default) {
|
|
996
|
-
prepend.push(
|
|
997
|
-
`${importType} SubscriptionResolver from '${parsedMapper.source}';`
|
|
998
|
-
);
|
|
974
|
+
prepend.push(`${importType} SubscriptionResolver from '${parsedMapper.source}';`);
|
|
999
975
|
} else {
|
|
1000
976
|
prepend.push(
|
|
1001
977
|
`${importType} { ${parsedMapper.import} ${parsedMapper.import !== "SubscriptionResolver" ? "as SubscriptionResolver " : ""}} from '${parsedMapper.source}';`
|
|
@@ -1114,9 +1090,6 @@ export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs
|
|
|
1114
1090
|
};
|
|
1115
1091
|
};
|
|
1116
1092
|
|
|
1117
|
-
// codegen.ts
|
|
1118
|
-
import path from "path";
|
|
1119
|
-
|
|
1120
1093
|
// utils/cache.ts
|
|
1121
1094
|
function createCache() {
|
|
1122
1095
|
const cache = /* @__PURE__ */ new Map();
|
|
@@ -1134,17 +1107,17 @@ function createCache() {
|
|
|
1134
1107
|
|
|
1135
1108
|
// utils/load.ts
|
|
1136
1109
|
import { getCachedDocumentNodeFromSchema as getCachedDocumentNodeFromSchema3 } from "@graphql-codegen/plugin-helpers";
|
|
1137
|
-
import {
|
|
1138
|
-
loadSchema as loadSchemaToolkit
|
|
1139
|
-
} from "@graphql-tools/load";
|
|
1110
|
+
import { ApolloEngineLoader } from "@graphql-tools/apollo-engine-loader";
|
|
1140
1111
|
import { CodeFileLoader } from "@graphql-tools/code-file-loader";
|
|
1141
1112
|
import { GitLoader } from "@graphql-tools/git-loader";
|
|
1142
1113
|
import { GithubLoader } from "@graphql-tools/github-loader";
|
|
1143
1114
|
import { GraphQLFileLoader } from "@graphql-tools/graphql-file-loader";
|
|
1144
1115
|
import { JsonFileLoader } from "@graphql-tools/json-file-loader";
|
|
1145
|
-
import {
|
|
1146
|
-
|
|
1116
|
+
import {
|
|
1117
|
+
loadSchema as loadSchemaToolkit
|
|
1118
|
+
} from "@graphql-tools/load";
|
|
1147
1119
|
import { PrismaLoader } from "@graphql-tools/prisma-loader";
|
|
1120
|
+
import { UrlLoader } from "@graphql-tools/url-loader";
|
|
1148
1121
|
|
|
1149
1122
|
// utils/hash.ts
|
|
1150
1123
|
import { getCachedDocumentNodeFromSchema as getCachedDocumentNodeFromSchema2 } from "@graphql-codegen/plugin-helpers";
|
|
@@ -1184,7 +1157,6 @@ async function loadSchema(schemaPointerMap, cwd) {
|
|
|
1184
1157
|
}
|
|
1185
1158
|
|
|
1186
1159
|
// codegen.ts
|
|
1187
|
-
import { File } from "@baeta/plugin";
|
|
1188
1160
|
async function generate(options) {
|
|
1189
1161
|
const root = process.cwd();
|
|
1190
1162
|
const modulesDir = path.relative(root, options.modulesDir || "modules");
|
package/package.json
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baeta/plugin-graphql",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "Andrei Pampu <pampu.andrei@pm.me>",
|
|
6
|
+
"homepage": "https://github.com/andreisergiu98/baeta#readme",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/andreisergiu98/baeta.git",
|
|
10
|
+
"directory": "plugins/graphql"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/andreisergiu98/baeta/issues"
|
|
14
|
+
},
|
|
4
15
|
"type": "module",
|
|
5
16
|
"scripts": {
|
|
6
17
|
"prepack": "yarn prep --move dist",
|
|
7
18
|
"postpack": "yarn prep --clean",
|
|
8
|
-
"build": "yarn tsup --dts"
|
|
19
|
+
"build": "yarn tsup --dts",
|
|
20
|
+
"lint": "yarn eslint './**/*.ts'"
|
|
9
21
|
},
|
|
10
22
|
"dependencies": {
|
|
11
|
-
"@baeta/plugin": "^0.0.
|
|
23
|
+
"@baeta/plugin": "^0.0.5",
|
|
12
24
|
"@graphql-codegen/core": "^2.6.2",
|
|
13
25
|
"@graphql-codegen/plugin-helpers": "^2.7.1",
|
|
14
26
|
"@graphql-codegen/typescript": "^2.7.3",
|
|
@@ -21,8 +33,8 @@
|
|
|
21
33
|
"@graphql-tools/graphql-file-loader": "^7.5.5",
|
|
22
34
|
"@graphql-tools/json-file-loader": "^7.4.6",
|
|
23
35
|
"@graphql-tools/load": "^7.7.7",
|
|
24
|
-
"@graphql-tools/prisma-loader": "^7.2.
|
|
25
|
-
"@graphql-tools/url-loader": "^7.16.
|
|
36
|
+
"@graphql-tools/prisma-loader": "^7.2.24",
|
|
37
|
+
"@graphql-tools/url-loader": "^7.16.4",
|
|
26
38
|
"@graphql-tools/utils": "^8.12.0",
|
|
27
39
|
"auto-bind": "^5.0.1",
|
|
28
40
|
"change-case-all": "1.0.15",
|
|
@@ -30,20 +42,23 @@
|
|
|
30
42
|
"tslib": "^2.4.0"
|
|
31
43
|
},
|
|
32
44
|
"devDependencies": {
|
|
45
|
+
"@baeta/eslint-config": "^0.0.0",
|
|
33
46
|
"@baeta/prep": "^0.0.0",
|
|
34
|
-
"@types/node": "^18.
|
|
47
|
+
"@types/node": "^18.8.1",
|
|
35
48
|
"@types/parse-filepath": "1.0.0",
|
|
49
|
+
"eslint": "^8.24.0",
|
|
36
50
|
"graphql": "^16.6.0",
|
|
37
51
|
"typescript": "^4.8.3"
|
|
38
52
|
},
|
|
39
53
|
"peerDependencies": {
|
|
40
|
-
"@baeta/core": "^0.0.
|
|
54
|
+
"@baeta/core": "^0.0.12",
|
|
41
55
|
"graphql": "^15.3.0 || ^16.0.0"
|
|
42
56
|
},
|
|
43
57
|
"files": [
|
|
44
58
|
"*.js",
|
|
45
59
|
"*.cjs",
|
|
46
|
-
"*.d.ts"
|
|
60
|
+
"*.d.ts",
|
|
61
|
+
"!.eslintrc.cjs"
|
|
47
62
|
],
|
|
48
63
|
"publishConfig": {
|
|
49
64
|
"access": "public",
|