@baeta/plugin-graphql 0.0.17 → 0.0.19
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 +20 -0
- package/dist/index.cjs +33 -39
- package/dist/index.d.ts +2 -3
- package/dist/index.js +33 -39
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @baeta/plugin-graphql
|
|
2
2
|
|
|
3
|
+
## 0.0.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#40](https://github.com/andreisergiu98/baeta/pull/40) [`9f937f4`](https://github.com/andreisergiu98/baeta/commit/9f937f47d3464a082680047414ee13a76cf6c056) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - normalize config
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`9f937f4`](https://github.com/andreisergiu98/baeta/commit/9f937f47d3464a082680047414ee13a76cf6c056), [`9f937f4`](https://github.com/andreisergiu98/baeta/commit/9f937f47d3464a082680047414ee13a76cf6c056)]:
|
|
10
|
+
- @baeta/generator-sdk@0.0.5
|
|
11
|
+
|
|
12
|
+
## 0.0.18
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [`d1190c1`](https://github.com/andreisergiu98/baeta/commit/d1190c10e3c259c73ddeeb73a4bd312b22bf2ea4) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - create cli sdk
|
|
17
|
+
release prisma plugin
|
|
18
|
+
update dependencies
|
|
19
|
+
refactor generator plugins
|
|
20
|
+
- Updated dependencies [[`d1190c1`](https://github.com/andreisergiu98/baeta/commit/d1190c10e3c259c73ddeeb73a4bd312b22bf2ea4)]:
|
|
21
|
+
- @baeta/generator-sdk@0.0.4
|
|
22
|
+
|
|
3
23
|
## 0.0.17
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -12,7 +12,6 @@ var _generatorsdk = require('@baeta/generator-sdk');
|
|
|
12
12
|
var _core = require('@graphql-codegen/core');
|
|
13
13
|
var _pluginhelpers = require('@graphql-codegen/plugin-helpers');
|
|
14
14
|
var _typescript = require('@graphql-codegen/typescript'); var typescriptPlugin = _interopRequireWildcard(_typescript);
|
|
15
|
-
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
16
15
|
|
|
17
16
|
// utils/cache.ts
|
|
18
17
|
function createCache() {
|
|
@@ -117,7 +116,7 @@ var context_default = { plugin };
|
|
|
117
116
|
// lib/modules/index.ts
|
|
118
117
|
|
|
119
118
|
|
|
120
|
-
|
|
119
|
+
var _path = require('path');
|
|
121
120
|
|
|
122
121
|
// lib/modules/builder.ts
|
|
123
122
|
var _changecaseall = require('change-case-all');
|
|
@@ -297,18 +296,18 @@ function extractModuleDirectory(filepath, basePath) {
|
|
|
297
296
|
const [moduleDirectory] = relativePath.split(sep);
|
|
298
297
|
return moduleDirectory;
|
|
299
298
|
}
|
|
300
|
-
function stripFilename(
|
|
301
|
-
const parsedPath = _parsefilepath2.default.call(void 0,
|
|
299
|
+
function stripFilename(path) {
|
|
300
|
+
const parsedPath = _parsefilepath2.default.call(void 0, path);
|
|
302
301
|
return normalize(parsedPath.dir);
|
|
303
302
|
}
|
|
304
|
-
function normalize(
|
|
305
|
-
return
|
|
303
|
+
function normalize(path) {
|
|
304
|
+
return path.replace(/\\/g, "/");
|
|
306
305
|
}
|
|
307
|
-
function ensureEndsWithSeparator(
|
|
308
|
-
return
|
|
306
|
+
function ensureEndsWithSeparator(path) {
|
|
307
|
+
return path.endsWith(sep) ? path : path + sep;
|
|
309
308
|
}
|
|
310
|
-
function ensureStartsWithSeparator(
|
|
311
|
-
return
|
|
309
|
+
function ensureStartsWithSeparator(path) {
|
|
310
|
+
return path.startsWith(".") ? path.replace(/^(..\/)|(.\/)/, "/") : path.startsWith("/") ? path : `/${path}`;
|
|
312
311
|
}
|
|
313
312
|
function pushUnique(list, item) {
|
|
314
313
|
if (!list.includes(item)) {
|
|
@@ -806,15 +805,12 @@ var preset = {
|
|
|
806
805
|
|
|
807
806
|
// lib/codegen.ts
|
|
808
807
|
async function generate(options) {
|
|
809
|
-
const root = process.cwd();
|
|
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);
|
|
812
808
|
const rootConfig = {
|
|
813
809
|
schemas: _pluginhelpers.normalizeInstanceOrArray.call(void 0, options.schemas),
|
|
814
|
-
modulesDir,
|
|
815
|
-
baseTypesPath:
|
|
810
|
+
modulesDir: options.modulesDir,
|
|
811
|
+
baseTypesPath: options.baseTypesPath,
|
|
816
812
|
contextType: options.contextType,
|
|
817
|
-
moduleDefinitionName: options.moduleDefinitionName
|
|
813
|
+
moduleDefinitionName: options.moduleDefinitionName,
|
|
818
814
|
scalars: options.scalars,
|
|
819
815
|
plugins: _pluginhelpers.normalizeConfig.call(void 0, ["typescript", "context"]),
|
|
820
816
|
pluginMap: {
|
|
@@ -833,15 +829,15 @@ async function generate(options) {
|
|
|
833
829
|
}
|
|
834
830
|
const hash = JSON.stringify(schemaPointerMap);
|
|
835
831
|
const result = await cache("schema", hash, async () => {
|
|
836
|
-
return loadSchema(schemaPointerMap,
|
|
832
|
+
return loadSchema(schemaPointerMap, options.cwd);
|
|
837
833
|
});
|
|
838
834
|
const outputs = await preset.buildGeneratesSection({
|
|
839
|
-
baseOutputDir: modulesDir,
|
|
835
|
+
baseOutputDir: options.modulesDir,
|
|
840
836
|
presetConfig: {
|
|
841
837
|
baseTypesPath: rootConfig.baseTypesPath,
|
|
842
838
|
filename: rootConfig.moduleDefinitionName,
|
|
843
839
|
encapsulateModuleTypes: "none",
|
|
844
|
-
extensionsPath
|
|
840
|
+
extensionsPath: options.extensions
|
|
845
841
|
},
|
|
846
842
|
schema: result.outputSchema,
|
|
847
843
|
schemaAst: result.outputSchemaAst,
|
|
@@ -853,11 +849,6 @@ async function generate(options) {
|
|
|
853
849
|
contextType: rootConfig.contextType,
|
|
854
850
|
useTypeImports: true,
|
|
855
851
|
scalars: {
|
|
856
|
-
BigInt: "number",
|
|
857
|
-
Bytes: "Buffer",
|
|
858
|
-
DateTime: "Date",
|
|
859
|
-
Decimal: "number",
|
|
860
|
-
Json: "{}",
|
|
861
852
|
...rootConfig.scalars
|
|
862
853
|
}
|
|
863
854
|
}
|
|
@@ -873,20 +864,23 @@ async function generate(options) {
|
|
|
873
864
|
}
|
|
874
865
|
|
|
875
866
|
// index.ts
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
867
|
+
function graphqlPlugin() {
|
|
868
|
+
return _generatorsdk.createPluginV1.call(void 0, {
|
|
869
|
+
name: "graphql",
|
|
870
|
+
actionName: "GraphQL modules",
|
|
871
|
+
watch: (options) => {
|
|
872
|
+
return {
|
|
873
|
+
include: options.schemas,
|
|
874
|
+
ignore: []
|
|
875
|
+
};
|
|
876
|
+
},
|
|
877
|
+
generate: async (ctx, next) => {
|
|
878
|
+
const files = await generate(ctx.generatorOptions);
|
|
879
|
+
ctx.fileManager.add(...files);
|
|
880
|
+
return next();
|
|
881
|
+
}
|
|
882
|
+
});
|
|
883
|
+
}
|
|
890
884
|
|
|
891
885
|
|
|
892
|
-
exports.
|
|
886
|
+
exports.graphqlPlugin = graphqlPlugin;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as _baeta_generator_sdk from '@baeta/generator-sdk';
|
|
2
|
-
import { GeneratorOptions } from '@baeta/generator-sdk';
|
|
3
2
|
|
|
4
|
-
declare
|
|
3
|
+
declare function graphqlPlugin(): _baeta_generator_sdk.GeneratorPluginV1<{}>;
|
|
5
4
|
|
|
6
|
-
export {
|
|
5
|
+
export { graphqlPlugin };
|
package/dist/index.js
CHANGED
|
@@ -5,14 +5,13 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// index.ts
|
|
8
|
-
import {
|
|
8
|
+
import { createPluginV1 } from "@baeta/generator-sdk";
|
|
9
9
|
|
|
10
10
|
// lib/codegen.ts
|
|
11
11
|
import { File } from "@baeta/generator-sdk";
|
|
12
12
|
import { codegen as gqlCodegen } from "@graphql-codegen/core";
|
|
13
13
|
import { normalizeConfig, normalizeInstanceOrArray } from "@graphql-codegen/plugin-helpers";
|
|
14
14
|
import * as typescriptPlugin from "@graphql-codegen/typescript";
|
|
15
|
-
import path from "path";
|
|
16
15
|
|
|
17
16
|
// utils/cache.ts
|
|
18
17
|
function createCache() {
|
|
@@ -297,18 +296,18 @@ function extractModuleDirectory(filepath, basePath) {
|
|
|
297
296
|
const [moduleDirectory] = relativePath.split(sep);
|
|
298
297
|
return moduleDirectory;
|
|
299
298
|
}
|
|
300
|
-
function stripFilename(
|
|
301
|
-
const parsedPath = parse(
|
|
299
|
+
function stripFilename(path) {
|
|
300
|
+
const parsedPath = parse(path);
|
|
302
301
|
return normalize(parsedPath.dir);
|
|
303
302
|
}
|
|
304
|
-
function normalize(
|
|
305
|
-
return
|
|
303
|
+
function normalize(path) {
|
|
304
|
+
return path.replace(/\\/g, "/");
|
|
306
305
|
}
|
|
307
|
-
function ensureEndsWithSeparator(
|
|
308
|
-
return
|
|
306
|
+
function ensureEndsWithSeparator(path) {
|
|
307
|
+
return path.endsWith(sep) ? path : path + sep;
|
|
309
308
|
}
|
|
310
|
-
function ensureStartsWithSeparator(
|
|
311
|
-
return
|
|
309
|
+
function ensureStartsWithSeparator(path) {
|
|
310
|
+
return path.startsWith(".") ? path.replace(/^(..\/)|(.\/)/, "/") : path.startsWith("/") ? path : `/${path}`;
|
|
312
311
|
}
|
|
313
312
|
function pushUnique(list, item) {
|
|
314
313
|
if (!list.includes(item)) {
|
|
@@ -806,15 +805,12 @@ var preset = {
|
|
|
806
805
|
|
|
807
806
|
// lib/codegen.ts
|
|
808
807
|
async function generate(options) {
|
|
809
|
-
const root = process.cwd();
|
|
810
|
-
const modulesDir = path.relative(root, options.modulesDir || "modules");
|
|
811
|
-
const extensionsPath = options.extensions && path.relative(path.join(modulesDir, "module"), options.extensions);
|
|
812
808
|
const rootConfig = {
|
|
813
809
|
schemas: normalizeInstanceOrArray(options.schemas),
|
|
814
|
-
modulesDir,
|
|
815
|
-
baseTypesPath:
|
|
810
|
+
modulesDir: options.modulesDir,
|
|
811
|
+
baseTypesPath: options.baseTypesPath,
|
|
816
812
|
contextType: options.contextType,
|
|
817
|
-
moduleDefinitionName: options.moduleDefinitionName
|
|
813
|
+
moduleDefinitionName: options.moduleDefinitionName,
|
|
818
814
|
scalars: options.scalars,
|
|
819
815
|
plugins: normalizeConfig(["typescript", "context"]),
|
|
820
816
|
pluginMap: {
|
|
@@ -833,15 +829,15 @@ async function generate(options) {
|
|
|
833
829
|
}
|
|
834
830
|
const hash = JSON.stringify(schemaPointerMap);
|
|
835
831
|
const result = await cache("schema", hash, async () => {
|
|
836
|
-
return loadSchema(schemaPointerMap,
|
|
832
|
+
return loadSchema(schemaPointerMap, options.cwd);
|
|
837
833
|
});
|
|
838
834
|
const outputs = await preset.buildGeneratesSection({
|
|
839
|
-
baseOutputDir: modulesDir,
|
|
835
|
+
baseOutputDir: options.modulesDir,
|
|
840
836
|
presetConfig: {
|
|
841
837
|
baseTypesPath: rootConfig.baseTypesPath,
|
|
842
838
|
filename: rootConfig.moduleDefinitionName,
|
|
843
839
|
encapsulateModuleTypes: "none",
|
|
844
|
-
extensionsPath
|
|
840
|
+
extensionsPath: options.extensions
|
|
845
841
|
},
|
|
846
842
|
schema: result.outputSchema,
|
|
847
843
|
schemaAst: result.outputSchemaAst,
|
|
@@ -853,11 +849,6 @@ async function generate(options) {
|
|
|
853
849
|
contextType: rootConfig.contextType,
|
|
854
850
|
useTypeImports: true,
|
|
855
851
|
scalars: {
|
|
856
|
-
BigInt: "number",
|
|
857
|
-
Bytes: "Buffer",
|
|
858
|
-
DateTime: "Date",
|
|
859
|
-
Decimal: "number",
|
|
860
|
-
Json: "{}",
|
|
861
852
|
...rootConfig.scalars
|
|
862
853
|
}
|
|
863
854
|
}
|
|
@@ -873,20 +864,23 @@ async function generate(options) {
|
|
|
873
864
|
}
|
|
874
865
|
|
|
875
866
|
// index.ts
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
867
|
+
function graphqlPlugin() {
|
|
868
|
+
return createPluginV1({
|
|
869
|
+
name: "graphql",
|
|
870
|
+
actionName: "GraphQL modules",
|
|
871
|
+
watch: (options) => {
|
|
872
|
+
return {
|
|
873
|
+
include: options.schemas,
|
|
874
|
+
ignore: []
|
|
875
|
+
};
|
|
876
|
+
},
|
|
877
|
+
generate: async (ctx, next) => {
|
|
878
|
+
const files = await generate(ctx.generatorOptions);
|
|
879
|
+
ctx.fileManager.add(...files);
|
|
880
|
+
return next();
|
|
881
|
+
}
|
|
882
|
+
});
|
|
883
|
+
}
|
|
890
884
|
export {
|
|
891
|
-
|
|
885
|
+
graphqlPlugin
|
|
892
886
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baeta/plugin-graphql",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"homepage": "https://github.com/andreisergiu98/baeta#readme",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/andreisergiu98/baeta/issues"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"types": "tsc --noEmit"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@baeta/generator-sdk": "^0.0.
|
|
27
|
+
"@baeta/generator-sdk": "^0.0.5",
|
|
28
28
|
"@graphql-codegen/core": "^2.6.8",
|
|
29
29
|
"@graphql-codegen/plugin-helpers": "^3.1.2",
|
|
30
30
|
"@graphql-codegen/typescript": "^2.8.7",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"@graphql-tools/graphql-file-loader": "^7.5.14",
|
|
37
37
|
"@graphql-tools/json-file-loader": "^7.4.15",
|
|
38
38
|
"@graphql-tools/load": "^7.8.9",
|
|
39
|
-
"@graphql-tools/prisma-loader": "^7.2.
|
|
40
|
-
"@graphql-tools/url-loader": "^7.17.
|
|
39
|
+
"@graphql-tools/prisma-loader": "^7.2.54",
|
|
40
|
+
"@graphql-tools/url-loader": "^7.17.3",
|
|
41
41
|
"@graphql-tools/utils": "^9.1.4",
|
|
42
42
|
"auto-bind": "^5.0.1",
|
|
43
43
|
"change-case-all": "1.0.15",
|
|
@@ -45,13 +45,13 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@baeta/build-tools": "^0.0.0",
|
|
48
|
+
"@baeta/tsconfig": "^0.0.0",
|
|
48
49
|
"@types/node": "^18.11.18",
|
|
49
50
|
"@types/parse-filepath": "1.0.0",
|
|
50
51
|
"graphql": "^16.6.0",
|
|
51
52
|
"typescript": "^4.9.4"
|
|
52
53
|
},
|
|
53
54
|
"peerDependencies": {
|
|
54
|
-
"@baeta/generator": "^0.0.18",
|
|
55
55
|
"graphql": "^16.6.0"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|