@baeta/plugin-graphql 0.0.13 → 0.0.14
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 +10 -0
- package/index.cjs +13 -4
- package/index.js +13 -4
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @baeta/plugin-graphql
|
|
2
2
|
|
|
3
|
+
## 0.0.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`dfaf0dc`](https://github.com/andreisergiu98/baeta/commit/dfaf0dc108244b0ada332ab978aa7f39fbfe7e7d) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - add generator support for runtime extensions
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`dfaf0dc`](https://github.com/andreisergiu98/baeta/commit/dfaf0dc108244b0ada332ab978aa7f39fbfe7e7d)]:
|
|
10
|
+
- @baeta/config@0.0.8
|
|
11
|
+
- @baeta/plugin@0.0.13
|
|
12
|
+
|
|
3
13
|
## 0.0.13
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/index.cjs
CHANGED
|
@@ -348,7 +348,8 @@ function buildModule(name, doc, {
|
|
|
348
348
|
schema,
|
|
349
349
|
baseVisitor,
|
|
350
350
|
fieldTypes,
|
|
351
|
-
fieldArguments
|
|
351
|
+
fieldArguments,
|
|
352
|
+
extensionsPath
|
|
352
353
|
}) {
|
|
353
354
|
const picks = createObject(
|
|
354
355
|
registryKeys,
|
|
@@ -405,6 +406,10 @@ function buildModule(name, doc, {
|
|
|
405
406
|
'import { DocumentNode } from "graphql";',
|
|
406
407
|
'import * as Baeta from "@baeta/core/sdk";'
|
|
407
408
|
];
|
|
409
|
+
if (extensionsPath) {
|
|
410
|
+
imports.push(`import baetaExtensions from "${extensionsPath}";`);
|
|
411
|
+
}
|
|
412
|
+
imports.push("\n");
|
|
408
413
|
let content = [
|
|
409
414
|
printDefinedFields(),
|
|
410
415
|
printDefinedEnumValues(),
|
|
@@ -451,8 +456,9 @@ ${shouldDeclare ? `${indent(2)(imports.join("\n"))}
|
|
|
451
456
|
const name2 = moduleNamespace.slice(0, moduleNamespace.length - 6);
|
|
452
457
|
const createModuleFn = `create${name2}Module`;
|
|
453
458
|
const getModuleFn = `get${name2}Module`;
|
|
459
|
+
const extensionsArg = extensionsPath ? ", baetaExtensions" : "";
|
|
454
460
|
return `
|
|
455
|
-
export const ${createModuleFn} = () => Baeta.createModuleManager(ModuleMetadata);
|
|
461
|
+
export const ${createModuleFn} = () => Baeta.createModuleManager(ModuleMetadata${extensionsArg});
|
|
456
462
|
export const ${getModuleFn} = Baeta.createSingletonModule(${createModuleFn});
|
|
457
463
|
`;
|
|
458
464
|
}
|
|
@@ -697,7 +703,7 @@ ${body}
|
|
|
697
703
|
var preset = {
|
|
698
704
|
buildGeneratesSection: (options) => {
|
|
699
705
|
const { baseOutputDir } = options;
|
|
700
|
-
const { baseTypesPath, encapsulateModuleTypes } = options.presetConfig;
|
|
706
|
+
const { baseTypesPath, extensionsPath, encapsulateModuleTypes } = options.presetConfig;
|
|
701
707
|
const requireRootResolvers = _visitorplugincommon.getConfigValue.call(void 0, _optionalChain([options, 'optionalAccess', _16 => _16.presetConfig, 'access', _17 => _17.requireRootResolvers]), false);
|
|
702
708
|
const cwd = _path.resolve.call(void 0, options.presetConfig.cwd || process.cwd());
|
|
703
709
|
const importTypesNamespace = options.presetConfig.importTypesNamespace || "Types";
|
|
@@ -781,6 +787,7 @@ var preset = {
|
|
|
781
787
|
useGraphQLModules: false,
|
|
782
788
|
fieldTypes,
|
|
783
789
|
fieldArguments,
|
|
790
|
+
extensionsPath,
|
|
784
791
|
rootTypes: [
|
|
785
792
|
_optionalChain([schema, 'access', _24 => _24.getQueryType, 'call', _25 => _25(), 'optionalAccess', _26 => _26.name]) || "",
|
|
786
793
|
_optionalChain([schema, 'access', _27 => _27.getMutationType, 'call', _28 => _28(), 'optionalAccess', _29 => _29.name]) || "",
|
|
@@ -801,6 +808,7 @@ var preset = {
|
|
|
801
808
|
async function generate(options) {
|
|
802
809
|
const root = process.cwd();
|
|
803
810
|
const modulesDir = _path2.default.relative(root, options.modulesDir || "modules");
|
|
811
|
+
const extensionsPath = options.extensions && _path2.default.relative(_path2.default.join(modulesDir, "module"), options.extensions);
|
|
804
812
|
const rootConfig = {
|
|
805
813
|
schemas: _pluginhelpers.normalizeInstanceOrArray.call(void 0, options.schemas),
|
|
806
814
|
modulesDir,
|
|
@@ -832,7 +840,8 @@ async function generate(options) {
|
|
|
832
840
|
presetConfig: {
|
|
833
841
|
baseTypesPath: rootConfig.baseTypesPath,
|
|
834
842
|
filename: rootConfig.moduleDefinitionName,
|
|
835
|
-
encapsulateModuleTypes: "none"
|
|
843
|
+
encapsulateModuleTypes: "none",
|
|
844
|
+
extensionsPath
|
|
836
845
|
},
|
|
837
846
|
schema: result.outputSchema,
|
|
838
847
|
schemaAst: result.outputSchemaAst,
|
package/index.js
CHANGED
|
@@ -348,7 +348,8 @@ function buildModule(name, doc, {
|
|
|
348
348
|
schema,
|
|
349
349
|
baseVisitor,
|
|
350
350
|
fieldTypes,
|
|
351
|
-
fieldArguments
|
|
351
|
+
fieldArguments,
|
|
352
|
+
extensionsPath
|
|
352
353
|
}) {
|
|
353
354
|
const picks = createObject(
|
|
354
355
|
registryKeys,
|
|
@@ -405,6 +406,10 @@ function buildModule(name, doc, {
|
|
|
405
406
|
'import { DocumentNode } from "graphql";',
|
|
406
407
|
'import * as Baeta from "@baeta/core/sdk";'
|
|
407
408
|
];
|
|
409
|
+
if (extensionsPath) {
|
|
410
|
+
imports.push(`import baetaExtensions from "${extensionsPath}";`);
|
|
411
|
+
}
|
|
412
|
+
imports.push("\n");
|
|
408
413
|
let content = [
|
|
409
414
|
printDefinedFields(),
|
|
410
415
|
printDefinedEnumValues(),
|
|
@@ -451,8 +456,9 @@ ${shouldDeclare ? `${indent(2)(imports.join("\n"))}
|
|
|
451
456
|
const name2 = moduleNamespace.slice(0, moduleNamespace.length - 6);
|
|
452
457
|
const createModuleFn = `create${name2}Module`;
|
|
453
458
|
const getModuleFn = `get${name2}Module`;
|
|
459
|
+
const extensionsArg = extensionsPath ? ", baetaExtensions" : "";
|
|
454
460
|
return `
|
|
455
|
-
export const ${createModuleFn} = () => Baeta.createModuleManager(ModuleMetadata);
|
|
461
|
+
export const ${createModuleFn} = () => Baeta.createModuleManager(ModuleMetadata${extensionsArg});
|
|
456
462
|
export const ${getModuleFn} = Baeta.createSingletonModule(${createModuleFn});
|
|
457
463
|
`;
|
|
458
464
|
}
|
|
@@ -697,7 +703,7 @@ ${body}
|
|
|
697
703
|
var preset = {
|
|
698
704
|
buildGeneratesSection: (options) => {
|
|
699
705
|
const { baseOutputDir } = options;
|
|
700
|
-
const { baseTypesPath, encapsulateModuleTypes } = options.presetConfig;
|
|
706
|
+
const { baseTypesPath, extensionsPath, encapsulateModuleTypes } = options.presetConfig;
|
|
701
707
|
const requireRootResolvers = getConfigValue(options?.presetConfig.requireRootResolvers, false);
|
|
702
708
|
const cwd = resolve(options.presetConfig.cwd || process.cwd());
|
|
703
709
|
const importTypesNamespace = options.presetConfig.importTypesNamespace || "Types";
|
|
@@ -781,6 +787,7 @@ var preset = {
|
|
|
781
787
|
useGraphQLModules: false,
|
|
782
788
|
fieldTypes,
|
|
783
789
|
fieldArguments,
|
|
790
|
+
extensionsPath,
|
|
784
791
|
rootTypes: [
|
|
785
792
|
schema.getQueryType()?.name || "",
|
|
786
793
|
schema.getMutationType()?.name || "",
|
|
@@ -801,6 +808,7 @@ var preset = {
|
|
|
801
808
|
async function generate(options) {
|
|
802
809
|
const root = process.cwd();
|
|
803
810
|
const modulesDir = path.relative(root, options.modulesDir || "modules");
|
|
811
|
+
const extensionsPath = options.extensions && path.relative(path.join(modulesDir, "module"), options.extensions);
|
|
804
812
|
const rootConfig = {
|
|
805
813
|
schemas: normalizeInstanceOrArray(options.schemas),
|
|
806
814
|
modulesDir,
|
|
@@ -832,7 +840,8 @@ async function generate(options) {
|
|
|
832
840
|
presetConfig: {
|
|
833
841
|
baseTypesPath: rootConfig.baseTypesPath,
|
|
834
842
|
filename: rootConfig.moduleDefinitionName,
|
|
835
|
-
encapsulateModuleTypes: "none"
|
|
843
|
+
encapsulateModuleTypes: "none",
|
|
844
|
+
extensionsPath
|
|
836
845
|
},
|
|
837
846
|
schema: result.outputSchema,
|
|
838
847
|
schemaAst: result.outputSchemaAst,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baeta/plugin-graphql",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Andrei Pampu <pampu.andrei@pm.me>",
|
|
6
6
|
"homepage": "https://github.com/andreisergiu98/baeta#readme",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"postpack": "yarn prep --clean"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@baeta/config": "^0.0.
|
|
24
|
-
"@baeta/plugin": "^0.0.
|
|
23
|
+
"@baeta/config": "^0.0.8",
|
|
24
|
+
"@baeta/plugin": "^0.0.13",
|
|
25
25
|
"@graphql-codegen/core": "^2.6.8",
|
|
26
26
|
"@graphql-codegen/plugin-helpers": "^3.1.2",
|
|
27
27
|
"@graphql-codegen/typescript": "^2.8.7",
|