@constructive-io/graphql-codegen 3.0.2 → 3.0.4
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/core/codegen/barrel.d.ts +10 -0
- package/core/codegen/barrel.js +26 -0
- package/core/generate.js +9 -10
- package/esm/core/codegen/barrel.d.ts +10 -0
- package/esm/core/codegen/barrel.js +25 -0
- package/esm/core/generate.js +9 -10
- package/package.json +4 -4
package/core/codegen/barrel.d.ts
CHANGED
|
@@ -29,6 +29,16 @@ export interface MainBarrelOptions {
|
|
|
29
29
|
hasInvalidation?: boolean;
|
|
30
30
|
}
|
|
31
31
|
export declare function generateMainBarrel(tables: CleanTable[], options?: MainBarrelOptions): string;
|
|
32
|
+
export interface RootBarrelOptions {
|
|
33
|
+
hasTypes?: boolean;
|
|
34
|
+
hasHooks?: boolean;
|
|
35
|
+
hasOrm?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generate the root index.ts barrel file for the output directory.
|
|
39
|
+
* Re-exports from subdirectories based on which generators are enabled.
|
|
40
|
+
*/
|
|
41
|
+
export declare function generateRootBarrel(options?: RootBarrelOptions): string;
|
|
32
42
|
/**
|
|
33
43
|
* Generate queries barrel including custom query operations
|
|
34
44
|
*/
|
package/core/codegen/barrel.js
CHANGED
|
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.generateQueriesBarrel = generateQueriesBarrel;
|
|
37
37
|
exports.generateMutationsBarrel = generateMutationsBarrel;
|
|
38
38
|
exports.generateMainBarrel = generateMainBarrel;
|
|
39
|
+
exports.generateRootBarrel = generateRootBarrel;
|
|
39
40
|
exports.generateCustomQueriesBarrel = generateCustomQueriesBarrel;
|
|
40
41
|
exports.generateCustomMutationsBarrel = generateCustomMutationsBarrel;
|
|
41
42
|
const t = __importStar(require("@babel/types"));
|
|
@@ -167,6 +168,31 @@ function generateMainBarrel(tables, options = {}) {
|
|
|
167
168
|
}
|
|
168
169
|
return (0, babel_ast_1.generateCode)(statements);
|
|
169
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Generate the root index.ts barrel file for the output directory.
|
|
173
|
+
* Re-exports from subdirectories based on which generators are enabled.
|
|
174
|
+
*/
|
|
175
|
+
function generateRootBarrel(options = {}) {
|
|
176
|
+
const { hasTypes = false, hasHooks = false, hasOrm = false } = options;
|
|
177
|
+
const statements = [];
|
|
178
|
+
if (hasTypes) {
|
|
179
|
+
statements.push(exportAllFrom('./types'));
|
|
180
|
+
}
|
|
181
|
+
if (hasHooks) {
|
|
182
|
+
statements.push(exportAllFrom('./hooks'));
|
|
183
|
+
}
|
|
184
|
+
if (hasOrm) {
|
|
185
|
+
statements.push(exportAllFrom('./orm'));
|
|
186
|
+
}
|
|
187
|
+
// Add file header as leading comment on first statement
|
|
188
|
+
if (statements.length > 0) {
|
|
189
|
+
(0, babel_ast_1.addJSDocComment)(statements[0], [
|
|
190
|
+
'Generated SDK - auto-generated, do not edit',
|
|
191
|
+
'@generated by @constructive-io/graphql-codegen',
|
|
192
|
+
]);
|
|
193
|
+
}
|
|
194
|
+
return (0, babel_ast_1.generateCode)(statements);
|
|
195
|
+
}
|
|
170
196
|
// ============================================================================
|
|
171
197
|
// Custom operation barrels (includes both table and custom hooks)
|
|
172
198
|
// ============================================================================
|
package/core/generate.js
CHANGED
|
@@ -14,6 +14,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
14
14
|
const introspect_1 = require("./introspect");
|
|
15
15
|
const pipeline_1 = require("./pipeline");
|
|
16
16
|
const codegen_1 = require("./codegen");
|
|
17
|
+
const barrel_1 = require("./codegen/barrel");
|
|
17
18
|
const orm_1 = require("./codegen/orm");
|
|
18
19
|
const shared_1 = require("./codegen/shared");
|
|
19
20
|
const output_1 = require("./output");
|
|
@@ -167,16 +168,14 @@ async function generate(options = {}) {
|
|
|
167
168
|
allFilesWritten.push(...(writeResult.filesWritten ?? []));
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
|
-
// Generate
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
export * from './orm';
|
|
179
|
-
`;
|
|
171
|
+
// Generate barrel file at output root
|
|
172
|
+
// This re-exports from the appropriate subdirectories based on which generators are enabled
|
|
173
|
+
if (!options.dryRun) {
|
|
174
|
+
const barrelContent = (0, barrel_1.generateRootBarrel)({
|
|
175
|
+
hasTypes: bothEnabled,
|
|
176
|
+
hasHooks: runReactQuery,
|
|
177
|
+
hasOrm: runOrm,
|
|
178
|
+
});
|
|
180
179
|
await (0, output_1.writeGeneratedFiles)([{ path: 'index.ts', content: barrelContent }], outputRoot, []);
|
|
181
180
|
}
|
|
182
181
|
const generators = [runReactQuery && 'React Query', runOrm && 'ORM'].filter(Boolean).join(' and ');
|
|
@@ -29,6 +29,16 @@ export interface MainBarrelOptions {
|
|
|
29
29
|
hasInvalidation?: boolean;
|
|
30
30
|
}
|
|
31
31
|
export declare function generateMainBarrel(tables: CleanTable[], options?: MainBarrelOptions): string;
|
|
32
|
+
export interface RootBarrelOptions {
|
|
33
|
+
hasTypes?: boolean;
|
|
34
|
+
hasHooks?: boolean;
|
|
35
|
+
hasOrm?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generate the root index.ts barrel file for the output directory.
|
|
39
|
+
* Re-exports from subdirectories based on which generators are enabled.
|
|
40
|
+
*/
|
|
41
|
+
export declare function generateRootBarrel(options?: RootBarrelOptions): string;
|
|
32
42
|
/**
|
|
33
43
|
* Generate queries barrel including custom query operations
|
|
34
44
|
*/
|
|
@@ -127,6 +127,31 @@ export function generateMainBarrel(tables, options = {}) {
|
|
|
127
127
|
}
|
|
128
128
|
return generateCode(statements);
|
|
129
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Generate the root index.ts barrel file for the output directory.
|
|
132
|
+
* Re-exports from subdirectories based on which generators are enabled.
|
|
133
|
+
*/
|
|
134
|
+
export function generateRootBarrel(options = {}) {
|
|
135
|
+
const { hasTypes = false, hasHooks = false, hasOrm = false } = options;
|
|
136
|
+
const statements = [];
|
|
137
|
+
if (hasTypes) {
|
|
138
|
+
statements.push(exportAllFrom('./types'));
|
|
139
|
+
}
|
|
140
|
+
if (hasHooks) {
|
|
141
|
+
statements.push(exportAllFrom('./hooks'));
|
|
142
|
+
}
|
|
143
|
+
if (hasOrm) {
|
|
144
|
+
statements.push(exportAllFrom('./orm'));
|
|
145
|
+
}
|
|
146
|
+
// Add file header as leading comment on first statement
|
|
147
|
+
if (statements.length > 0) {
|
|
148
|
+
addJSDocComment(statements[0], [
|
|
149
|
+
'Generated SDK - auto-generated, do not edit',
|
|
150
|
+
'@generated by @constructive-io/graphql-codegen',
|
|
151
|
+
]);
|
|
152
|
+
}
|
|
153
|
+
return generateCode(statements);
|
|
154
|
+
}
|
|
130
155
|
// ============================================================================
|
|
131
156
|
// Custom operation barrels (includes both table and custom hooks)
|
|
132
157
|
// ============================================================================
|
package/esm/core/generate.js
CHANGED
|
@@ -8,6 +8,7 @@ import path from 'path';
|
|
|
8
8
|
import { createSchemaSource, validateSourceOptions } from './introspect';
|
|
9
9
|
import { runCodegenPipeline, validateTablesFound } from './pipeline';
|
|
10
10
|
import { generate as generateReactQueryFiles } from './codegen';
|
|
11
|
+
import { generateRootBarrel } from './codegen/barrel';
|
|
11
12
|
import { generateOrm as generateOrmFiles } from './codegen/orm';
|
|
12
13
|
import { generateSharedTypes } from './codegen/shared';
|
|
13
14
|
import { writeGeneratedFiles } from './output';
|
|
@@ -161,16 +162,14 @@ export async function generate(options = {}) {
|
|
|
161
162
|
allFilesWritten.push(...(writeResult.filesWritten ?? []));
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
|
-
// Generate
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
export * from './orm';
|
|
173
|
-
`;
|
|
165
|
+
// Generate barrel file at output root
|
|
166
|
+
// This re-exports from the appropriate subdirectories based on which generators are enabled
|
|
167
|
+
if (!options.dryRun) {
|
|
168
|
+
const barrelContent = generateRootBarrel({
|
|
169
|
+
hasTypes: bothEnabled,
|
|
170
|
+
hasHooks: runReactQuery,
|
|
171
|
+
hasOrm: runOrm,
|
|
172
|
+
});
|
|
174
173
|
await writeGeneratedFiles([{ path: 'index.ts', content: barrelContent }], outputRoot, []);
|
|
175
174
|
}
|
|
176
175
|
const generators = [runReactQuery && 'React Query', runOrm && 'ORM'].filter(Boolean).join(' and ');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/graphql-codegen",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"description": "GraphQL SDK generator for Constructive databases with React Query hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@0no-co/graphql.web": "^1.1.2",
|
|
57
57
|
"@babel/generator": "^7.28.6",
|
|
58
58
|
"@babel/types": "^7.28.6",
|
|
59
|
-
"@constructive-io/graphql-server": "^3.0.
|
|
59
|
+
"@constructive-io/graphql-server": "^3.0.3",
|
|
60
60
|
"@constructive-io/graphql-types": "^2.14.0",
|
|
61
61
|
"@inquirerer/utils": "^3.2.0",
|
|
62
62
|
"@pgpmjs/core": "^5.0.1",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"oxfmt": "^0.26.0",
|
|
72
72
|
"pg-cache": "^2.0.0",
|
|
73
73
|
"pg-env": "^1.3.0",
|
|
74
|
-
"pgsql-client": "^2.0.
|
|
74
|
+
"pgsql-client": "^2.0.2",
|
|
75
75
|
"pgsql-seed": "^1.0.1",
|
|
76
76
|
"undici": "^7.19.0"
|
|
77
77
|
},
|
|
@@ -99,5 +99,5 @@
|
|
|
99
99
|
"tsx": "^4.21.0",
|
|
100
100
|
"typescript": "^5.9.3"
|
|
101
101
|
},
|
|
102
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "aa8ec75966a41a019eda2003b2d970f0a75608aa"
|
|
103
103
|
}
|