@baeta/plugin-graphql 0.0.2 → 0.0.3

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.
Files changed (44) hide show
  1. package/dist/index.cjs +1282 -0
  2. package/dist/index.d.ts +10 -3
  3. package/dist/index.js +1260 -21
  4. package/package.json +13 -12
  5. package/dist/codegen.d.ts +0 -6
  6. package/dist/codegen.js +0 -116
  7. package/dist/codegen.mjs +0 -89
  8. package/dist/config.d.ts +0 -10
  9. package/dist/config.js +0 -16
  10. package/dist/config.mjs +0 -0
  11. package/dist/index.mjs +0 -19
  12. package/dist/modules/builder.d.ts +0 -17
  13. package/dist/modules/builder.js +0 -439
  14. package/dist/modules/builder.mjs +0 -429
  15. package/dist/modules/config.d.ts +0 -11
  16. package/dist/modules/config.js +0 -16
  17. package/dist/modules/config.mjs +0 -0
  18. package/dist/modules/index.d.ts +0 -6
  19. package/dist/modules/index.js +0 -148
  20. package/dist/modules/index.mjs +0 -132
  21. package/dist/modules/utils.d.ts +0 -28
  22. package/dist/modules/utils.js +0 -209
  23. package/dist/modules/utils.mjs +0 -168
  24. package/dist/resolvers/config.d.ts +0 -16
  25. package/dist/resolvers/config.js +0 -16
  26. package/dist/resolvers/config.mjs +0 -0
  27. package/dist/resolvers/index.d.ts +0 -10
  28. package/dist/resolvers/index.js +0 -309
  29. package/dist/resolvers/index.mjs +0 -289
  30. package/dist/resolvers/visitor.d.ts +0 -29
  31. package/dist/resolvers/visitor.js +0 -139
  32. package/dist/resolvers/visitor.mjs +0 -111
  33. package/dist/utils/cache.d.ts +0 -3
  34. package/dist/utils/cache.js +0 -40
  35. package/dist/utils/cache.mjs +0 -16
  36. package/dist/utils/hash.d.ts +0 -6
  37. package/dist/utils/hash.js +0 -38
  38. package/dist/utils/hash.mjs +0 -13
  39. package/dist/utils/load.d.ts +0 -9
  40. package/dist/utils/load.js +0 -62
  41. package/dist/utils/load.mjs +0 -40
  42. package/dist/utils/path.d.ts +0 -3
  43. package/dist/utils/path.js +0 -37
  44. package/dist/utils/path.mjs +0 -7
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@baeta/plugin-graphql",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
+ "type": "module",
4
5
  "scripts": {
5
6
  "build": "tsup --dts"
6
7
  },
7
8
  "dependencies": {
8
- "@baeta/plugin": "^0.0.2",
9
+ "@baeta/plugin": "^0.0.3",
9
10
  "@graphql-codegen/core": "^2.6.2",
10
11
  "@graphql-codegen/plugin-helpers": "^2.7.1",
11
12
  "@graphql-codegen/typescript": "^2.7.3",
@@ -34,31 +35,31 @@
34
35
  "typescript": "^4.8.3"
35
36
  },
36
37
  "peerDependencies": {
37
- "@baeta/core": "^0.0.6",
38
+ "@baeta/core": "^0.0.7",
38
39
  "graphql": "^15.3.0 || ^16.0.0"
39
40
  },
40
41
  "files": [
41
42
  "dist"
42
43
  ],
44
+ "types": "./dist/index.d.ts",
43
45
  "publishConfig": {
44
46
  "access": "public",
45
- "main": "./dist/index.js",
46
- "module": "./dist/index.mjs",
47
- "types": "./dist/index.d.ts",
47
+ "main": "./dist/index.cjs",
48
+ "module": "./dist/index.js",
48
49
  "exports": {
49
50
  ".": {
50
- "import": "./dist/index.mjs",
51
- "require": "./dist/index.js",
51
+ "import": "./dist/index.js",
52
+ "require": "./dist/index.cjs",
52
53
  "types": "./dist/index.d.ts"
53
54
  }
54
55
  }
55
56
  },
56
- "main": "./dist/index.js",
57
- "module": "./dist/index.mjs",
57
+ "main": "./dist/index.cjs",
58
+ "module": "./dist/index.js",
58
59
  "exports": {
59
60
  ".": {
60
- "import": "./dist/index.mjs",
61
- "require": "./dist/index.js",
61
+ "import": "./dist/index.js",
62
+ "require": "./dist/index.cjs",
62
63
  "types": "./dist/index.d.ts"
63
64
  }
64
65
  }
package/dist/codegen.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { GraphqlPluginConfig } from './config.js';
2
- import { File } from '@baeta/plugin';
3
-
4
- declare function generate(options: GraphqlPluginConfig): Promise<File[]>;
5
-
6
- export { generate };
package/dist/codegen.js DELETED
@@ -1,116 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
- var codegen_exports = {};
26
- __export(codegen_exports, {
27
- generate: () => generate
28
- });
29
- module.exports = __toCommonJS(codegen_exports);
30
- var import_core = require("@graphql-codegen/core");
31
- var import_plugin_helpers = require("@graphql-codegen/plugin-helpers");
32
- var modules = __toESM(require("./modules"));
33
- var typescriptPlugin = __toESM(require("@graphql-codegen/typescript"));
34
- var typescriptResolversPlugin = __toESM(require("./resolvers"));
35
- var import_path = __toESM(require("path"));
36
- var import_cache = require("./utils/cache");
37
- var import_load2 = require("./utils/load");
38
- var import_plugin = require("@baeta/plugin");
39
- async function generate(options) {
40
- const root = process.cwd();
41
- const modulesDir = import_path.default.relative(root, options.modulesDir || "modules");
42
- const rootConfig = {
43
- schemas: (0, import_plugin_helpers.normalizeInstanceOrArray)(options.schemas),
44
- modulesDir,
45
- baseTypesPath: import_path.default.relative(
46
- modulesDir,
47
- options.baseTypesPath || "./__generated__/types.ts"
48
- ),
49
- contextType: options.contextType,
50
- moduleDefinitionName: options.moduleDefinitionName || "typedef.ts",
51
- scalars: options.scalars,
52
- plugins: (0, import_plugin_helpers.normalizeConfig)(["typescript", "typescript-resolvers"]),
53
- pluginMap: {
54
- typescript: typescriptPlugin,
55
- "typescript-resolvers": typescriptResolversPlugin
56
- }
57
- };
58
- const cache = (0, import_cache.createCache)();
59
- const schemaPointerMap = {};
60
- for (const ptr of rootConfig.schemas) {
61
- if (typeof ptr === "string") {
62
- schemaPointerMap[ptr] = {};
63
- } else if (typeof ptr === "object") {
64
- Object.assign(schemaPointerMap, ptr);
65
- }
66
- }
67
- const hash = JSON.stringify(schemaPointerMap);
68
- const result = await cache("schema", hash, async () => {
69
- return (0, import_load2.loadSchema)(schemaPointerMap, root);
70
- });
71
- const outputs = await modules.preset.buildGeneratesSection({
72
- baseOutputDir: modulesDir,
73
- presetConfig: {
74
- baseTypesPath: rootConfig.baseTypesPath,
75
- filename: rootConfig.moduleDefinitionName,
76
- encapsulateModuleTypes: "none"
77
- },
78
- schema: result.outputSchema,
79
- schemaAst: result.outputSchemaAst,
80
- documents: [],
81
- pluginMap: rootConfig.pluginMap,
82
- plugins: rootConfig.plugins,
83
- config: {
84
- useIndexSignature: true,
85
- inputMaybeValue: "T | undefined",
86
- mapperTypeSuffix: "Prisma",
87
- contextType: rootConfig.contextType,
88
- customResolverFn: "@baeta/core#Resolver",
89
- customSubscriptionResolver: "@baeta/core#SubscriptionResolver",
90
- useTypeImports: true,
91
- makeResolverTypeCallable: true,
92
- includeDirectives: true,
93
- resolverTypeWrapperSignature: "T",
94
- scalars: {
95
- BigInt: "number",
96
- Bytes: "Buffer",
97
- DateTime: "Date",
98
- Decimal: "number",
99
- Json: "{}",
100
- ...rootConfig.scalars
101
- }
102
- }
103
- });
104
- const promises = outputs.map(async (output) => {
105
- const result2 = await (0, import_core.codegen)({
106
- ...output,
107
- cache
108
- });
109
- return new import_plugin.File(output.filename, result2, "graphql");
110
- });
111
- return Promise.all(promises);
112
- }
113
- // Annotate the CommonJS export names for ESM import in node:
114
- 0 && (module.exports = {
115
- generate
116
- });
package/dist/codegen.mjs DELETED
@@ -1,89 +0,0 @@
1
- import { codegen as gqlCodegen } from "@graphql-codegen/core";
2
- import {
3
- normalizeConfig,
4
- normalizeInstanceOrArray
5
- } from "@graphql-codegen/plugin-helpers";
6
- import * as modules from "./modules";
7
- import * as typescriptPlugin from "@graphql-codegen/typescript";
8
- import * as typescriptResolversPlugin from "./resolvers";
9
- import path from "path";
10
- import { createCache } from "./utils/cache";
11
- import { loadSchema } from "./utils/load";
12
- import { File } from "@baeta/plugin";
13
- async function generate(options) {
14
- const root = process.cwd();
15
- const modulesDir = path.relative(root, options.modulesDir || "modules");
16
- const rootConfig = {
17
- schemas: normalizeInstanceOrArray(options.schemas),
18
- modulesDir,
19
- baseTypesPath: path.relative(
20
- modulesDir,
21
- options.baseTypesPath || "./__generated__/types.ts"
22
- ),
23
- contextType: options.contextType,
24
- moduleDefinitionName: options.moduleDefinitionName || "typedef.ts",
25
- scalars: options.scalars,
26
- plugins: normalizeConfig(["typescript", "typescript-resolvers"]),
27
- pluginMap: {
28
- typescript: typescriptPlugin,
29
- "typescript-resolvers": typescriptResolversPlugin
30
- }
31
- };
32
- const cache = createCache();
33
- const schemaPointerMap = {};
34
- for (const ptr of rootConfig.schemas) {
35
- if (typeof ptr === "string") {
36
- schemaPointerMap[ptr] = {};
37
- } else if (typeof ptr === "object") {
38
- Object.assign(schemaPointerMap, ptr);
39
- }
40
- }
41
- const hash = JSON.stringify(schemaPointerMap);
42
- const result = await cache("schema", hash, async () => {
43
- return loadSchema(schemaPointerMap, root);
44
- });
45
- const outputs = await modules.preset.buildGeneratesSection({
46
- baseOutputDir: modulesDir,
47
- presetConfig: {
48
- baseTypesPath: rootConfig.baseTypesPath,
49
- filename: rootConfig.moduleDefinitionName,
50
- encapsulateModuleTypes: "none"
51
- },
52
- schema: result.outputSchema,
53
- schemaAst: result.outputSchemaAst,
54
- documents: [],
55
- pluginMap: rootConfig.pluginMap,
56
- plugins: rootConfig.plugins,
57
- config: {
58
- useIndexSignature: true,
59
- inputMaybeValue: "T | undefined",
60
- mapperTypeSuffix: "Prisma",
61
- contextType: rootConfig.contextType,
62
- customResolverFn: "@baeta/core#Resolver",
63
- customSubscriptionResolver: "@baeta/core#SubscriptionResolver",
64
- useTypeImports: true,
65
- makeResolverTypeCallable: true,
66
- includeDirectives: true,
67
- resolverTypeWrapperSignature: "T",
68
- scalars: {
69
- BigInt: "number",
70
- Bytes: "Buffer",
71
- DateTime: "Date",
72
- Decimal: "number",
73
- Json: "{}",
74
- ...rootConfig.scalars
75
- }
76
- }
77
- });
78
- const promises = outputs.map(async (output) => {
79
- const result2 = await gqlCodegen({
80
- ...output,
81
- cache
82
- });
83
- return new File(output.filename, result2, "graphql");
84
- });
85
- return Promise.all(promises);
86
- }
87
- export {
88
- generate
89
- };
package/dist/config.d.ts DELETED
@@ -1,10 +0,0 @@
1
- interface GraphqlPluginConfig {
2
- schemas: string[];
3
- modulesDir?: string;
4
- moduleDefinitionName?: string;
5
- baseTypesPath?: string;
6
- contextType?: string;
7
- scalars?: Record<string, string>;
8
- }
9
-
10
- export { GraphqlPluginConfig };
package/dist/config.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var config_exports = {};
16
- module.exports = __toCommonJS(config_exports);
package/dist/config.mjs DELETED
File without changes
package/dist/index.mjs DELETED
@@ -1,19 +0,0 @@
1
- import { createPluginFactoryV1 } from "@baeta/plugin";
2
- import { generate } from "./codegen";
3
- var graphql_default = createPluginFactoryV1({
4
- name: "graphql",
5
- watch: (baetaConfig, pluginConfig) => {
6
- return {
7
- include: pluginConfig.schemas,
8
- ignore: []
9
- };
10
- },
11
- generate: async (params) => {
12
- const files = await generate(params.config);
13
- params.ctx.fileManager.add(...files);
14
- return params.next();
15
- }
16
- });
17
- export {
18
- graphql_default as default
19
- };
@@ -1,17 +0,0 @@
1
- import { DocumentNode, GraphQLSchema } from 'graphql';
2
- import { ModulesConfig } from './config.js';
3
- import { BaseVisitor } from '@graphql-codegen/visitor-plugin-common';
4
-
5
- declare function buildModule(name: string, doc: DocumentNode, { importNamespace, importPath, encapsulate, requireRootResolvers, shouldDeclare, rootTypes, schema, baseVisitor, }: {
6
- importNamespace: string;
7
- importPath: string;
8
- encapsulate: ModulesConfig["encapsulateModuleTypes"];
9
- requireRootResolvers: ModulesConfig["requireRootResolvers"];
10
- shouldDeclare: boolean;
11
- rootTypes: string[];
12
- baseVisitor: BaseVisitor;
13
- schema?: GraphQLSchema;
14
- useGraphQLModules: boolean;
15
- }): string;
16
-
17
- export { buildModule };