@constructive-io/graphql-codegen 4.40.5 → 4.41.0
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/cli/table-command-generator.js +141 -2
- package/core/codegen/mutation-keys.js +18 -0
- package/core/codegen/mutations.js +187 -0
- package/core/codegen/orm/client-generator.js +0 -6
- package/core/codegen/orm/model-generator.js +167 -5
- package/core/codegen/orm/select-types.d.ts +2 -1
- package/core/codegen/queries.js +1 -1
- package/core/codegen/templates/cli-utils.ts +4 -2
- package/core/codegen/templates/query-builder.ts +170 -1
- package/core/codegen/templates/select-types.ts +30 -1
- package/core/codegen/utils.d.ts +8 -0
- package/core/codegen/utils.js +39 -0
- package/esm/core/codegen/cli/table-command-generator.js +141 -2
- package/esm/core/codegen/mutation-keys.js +18 -0
- package/esm/core/codegen/mutations.js +188 -1
- package/esm/core/codegen/orm/client-generator.js +0 -6
- package/esm/core/codegen/orm/model-generator.js +168 -6
- package/esm/core/codegen/orm/select-types.d.ts +2 -1
- package/esm/core/codegen/queries.js +1 -1
- package/esm/core/codegen/utils.d.ts +8 -0
- package/esm/core/codegen/utils.js +31 -0
- package/esm/types/schema.d.ts +8 -0
- package/package.json +4 -4
- package/types/schema.d.ts +8 -0
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import * as t from '@babel/types';
|
|
8
8
|
import { singularize } from 'inflekt';
|
|
9
9
|
import { generateCode } from '../babel-ast';
|
|
10
|
-
import { getCreateInputTypeName, getCreateMutationName, getDeleteInputTypeName, getDeleteMutationName, getFilterTypeName, getGeneratedFileHeader, getOrderByTypeName, getPrimaryKeyInfo,
|
|
10
|
+
import { getCreateInputTypeName, getCreateMutationName, getDeleteInputTypeName, getDeleteMutationName, getFilterTypeName, getGeneratedFileHeader, getOrderByTypeName, getPrimaryKeyInfo, getTableNames, hasValidPrimaryKey, lcFirst, ucFirst, } from '../utils';
|
|
11
11
|
function createImportDeclaration(moduleSpecifier, namedImports, typeOnly = false) {
|
|
12
12
|
const specifiers = namedImports.map((name) => t.importSpecifier(t.identifier(name), t.identifier(name)));
|
|
13
13
|
const decl = t.importDeclaration(specifiers, t.stringLiteral(moduleSpecifier));
|
|
@@ -83,7 +83,10 @@ export function generateModelFile(table, _useSharedTypes, options, allTables) {
|
|
|
83
83
|
const pkField = pkFields[0];
|
|
84
84
|
const pluralQueryName = table.query?.all ?? pluralName;
|
|
85
85
|
const singleQueryName = table.query?.one;
|
|
86
|
-
|
|
86
|
+
// The unwrapped result key for findFirst/findOne — must be the friendly
|
|
87
|
+
// singular noun (e.g. "animal"), NOT the GraphQL by-id query name (e.g.
|
|
88
|
+
// "animalById"), so the surface aligns with the rest of the SDK.
|
|
89
|
+
const singleResultFieldName = singularName;
|
|
87
90
|
const createMutationName = table.query?.create ?? `create${typeName}`;
|
|
88
91
|
const updateMutationName = table.query?.update;
|
|
89
92
|
const deleteMutationName = table.query?.delete;
|
|
@@ -96,6 +99,12 @@ export function generateModelFile(table, _useSharedTypes, options, allTables) {
|
|
|
96
99
|
const jt = allTables?.find((tb) => tb.name === r.junctionTable);
|
|
97
100
|
return jt?.query?.delete != null;
|
|
98
101
|
});
|
|
102
|
+
// Detect which bulk mutations are available for this table
|
|
103
|
+
const bulkInsertMutationName = table.query?.bulkInsert ?? null;
|
|
104
|
+
const bulkUpsertMutationName = table.query?.bulkUpsert ?? null;
|
|
105
|
+
const bulkUpdateMutationName = table.query?.bulkUpdate ?? null;
|
|
106
|
+
const bulkDeleteMutationName = table.query?.bulkDelete ?? null;
|
|
107
|
+
const hasBulk = !!(bulkInsertMutationName || bulkUpsertMutationName || bulkUpdateMutationName || bulkDeleteMutationName);
|
|
99
108
|
const queryBuilderImports = [
|
|
100
109
|
'QueryBuilder',
|
|
101
110
|
'buildFindManyDocument',
|
|
@@ -105,6 +114,10 @@ export function generateModelFile(table, _useSharedTypes, options, allTables) {
|
|
|
105
114
|
'buildUpdateByPkDocument',
|
|
106
115
|
'buildDeleteByPkDocument',
|
|
107
116
|
...(needsJunctionRemove ? ['buildJunctionRemoveDocument'] : []),
|
|
117
|
+
...(bulkInsertMutationName ? ['buildBulkInsertDocument'] : []),
|
|
118
|
+
...(bulkUpsertMutationName ? ['buildBulkUpsertDocument'] : []),
|
|
119
|
+
...(bulkUpdateMutationName ? ['buildBulkUpdateDocument'] : []),
|
|
120
|
+
...(bulkDeleteMutationName ? ['buildBulkDeleteDocument'] : []),
|
|
108
121
|
];
|
|
109
122
|
statements.push(createImportDeclaration('../query-builder', queryBuilderImports));
|
|
110
123
|
statements.push(createImportDeclaration('../select-types', [
|
|
@@ -114,6 +127,7 @@ export function generateModelFile(table, _useSharedTypes, options, allTables) {
|
|
|
114
127
|
'CreateArgs',
|
|
115
128
|
'UpdateArgs',
|
|
116
129
|
'DeleteArgs',
|
|
130
|
+
...(hasBulk ? ['BulkInsertArgs', 'BulkUpsertArgs', 'BulkUpdateArgs', 'BulkDeleteArgs', 'BulkMutationResult'] : []),
|
|
117
131
|
'InferSelectResult',
|
|
118
132
|
'StrictSelect',
|
|
119
133
|
], true));
|
|
@@ -192,15 +206,17 @@ export function generateModelFile(table, _useSharedTypes, options, allTables) {
|
|
|
192
206
|
const findFirstTypeArgs = [
|
|
193
207
|
(sel) => sel,
|
|
194
208
|
() => t.tsTypeReference(t.identifier(whereTypeName)),
|
|
209
|
+
() => t.tsTypeReference(t.identifier(orderByTypeName)),
|
|
195
210
|
];
|
|
196
211
|
const argsType = (sel) => t.tsTypeReference(t.identifier('FindFirstArgs'), t.tsTypeParameterInstantiation(findFirstTypeArgs.map(fn => fn(sel))));
|
|
197
212
|
const retType = (sel) => t.tsTypeAnnotation(t.tsTypeReference(t.identifier('QueryBuilder'), t.tsTypeParameterInstantiation([
|
|
198
213
|
t.tsTypeLiteral([
|
|
199
|
-
t.tsPropertySignature(t.identifier(
|
|
200
|
-
t.
|
|
214
|
+
t.tsPropertySignature(t.identifier(singleResultFieldName), t.tsTypeAnnotation(t.tsUnionType([
|
|
215
|
+
t.tsTypeReference(t.identifier('InferSelectResult'), t.tsTypeParameterInstantiation([
|
|
201
216
|
t.tsTypeReference(t.identifier(relationTypeName)),
|
|
202
217
|
sel,
|
|
203
|
-
]))
|
|
218
|
+
])),
|
|
219
|
+
t.tsNullKeyword(),
|
|
204
220
|
]))),
|
|
205
221
|
]),
|
|
206
222
|
])));
|
|
@@ -213,6 +229,10 @@ export function generateModelFile(table, _useSharedTypes, options, allTables) {
|
|
|
213
229
|
const selectExpr = t.memberExpression(t.identifier('args'), t.identifier('select'));
|
|
214
230
|
const findFirstObjProps = [
|
|
215
231
|
t.objectProperty(t.identifier('where'), t.optionalMemberExpression(t.identifier('args'), t.identifier('where'), false, true)),
|
|
232
|
+
t.objectProperty(t.identifier('orderBy'), t.tsAsExpression(t.optionalMemberExpression(t.identifier('args'), t.identifier('orderBy'), false, true), t.tsUnionType([
|
|
233
|
+
t.tsArrayType(t.tsStringKeyword()),
|
|
234
|
+
t.tsUndefinedKeyword(),
|
|
235
|
+
]))),
|
|
216
236
|
];
|
|
217
237
|
const bodyArgs = [
|
|
218
238
|
t.stringLiteral(typeName),
|
|
@@ -220,9 +240,23 @@ export function generateModelFile(table, _useSharedTypes, options, allTables) {
|
|
|
220
240
|
selectExpr,
|
|
221
241
|
t.objectExpression(findFirstObjProps),
|
|
222
242
|
t.stringLiteral(whereTypeName),
|
|
243
|
+
t.stringLiteral(orderByTypeName),
|
|
223
244
|
t.identifier('connectionFieldsMap'),
|
|
224
245
|
];
|
|
225
|
-
|
|
246
|
+
const transformDataParam = t.identifier('data');
|
|
247
|
+
const transformedNodesProp = t.tsPropertySignature(t.identifier('nodes'), t.tsTypeAnnotation(t.tsArrayType(t.tsTypeReference(t.identifier('InferSelectResult'), t.tsTypeParameterInstantiation([
|
|
248
|
+
t.tsTypeReference(t.identifier(relationTypeName)),
|
|
249
|
+
sRef(),
|
|
250
|
+
])))));
|
|
251
|
+
transformedNodesProp.optional = true;
|
|
252
|
+
const transformedCollectionProp = t.tsPropertySignature(t.identifier(pluralQueryName), t.tsTypeAnnotation(t.tsTypeLiteral([transformedNodesProp])));
|
|
253
|
+
transformedCollectionProp.optional = true;
|
|
254
|
+
transformDataParam.typeAnnotation = t.tsTypeAnnotation(t.tsTypeLiteral([transformedCollectionProp]));
|
|
255
|
+
const firstNodeExpr = t.optionalMemberExpression(t.optionalMemberExpression(t.memberExpression(t.identifier('data'), t.identifier(pluralQueryName)), t.identifier('nodes'), false, true), t.numericLiteral(0), true, true);
|
|
256
|
+
const transformFn = t.arrowFunctionExpression([transformDataParam], t.objectExpression([
|
|
257
|
+
t.objectProperty(t.stringLiteral(singleResultFieldName), t.logicalExpression('??', firstNodeExpr, t.nullLiteral())),
|
|
258
|
+
]));
|
|
259
|
+
classBody.push(createClassMethod('findFirst', createTypeParam(selectTypeName), [implParam], retType(sRef()), buildMethodBody('buildFindFirstDocument', bodyArgs, 'query', typeName, singleResultFieldName, [t.objectProperty(t.identifier('transform'), transformFn)])));
|
|
226
260
|
}
|
|
227
261
|
// ── findOne ────────────────────────────────────────────────────────────
|
|
228
262
|
if (hasValidPrimaryKey(table)) {
|
|
@@ -413,6 +447,134 @@ export function generateModelFile(table, _useSharedTypes, options, allTables) {
|
|
|
413
447
|
];
|
|
414
448
|
classBody.push(createClassMethod('delete', createTypeParam(selectTypeName), [implParam], retType(sRef()), buildMethodBody('buildDeleteByPkDocument', bodyArgs, 'mutation', typeName, deleteMutationName)));
|
|
415
449
|
}
|
|
450
|
+
// ── bulkCreate ──────────────────────────────────────────────────────────
|
|
451
|
+
if (bulkInsertMutationName) {
|
|
452
|
+
const bulkInsertInputTypeName = `BulkCreate${typeName}Input`;
|
|
453
|
+
const dataType = () => t.tsIndexedAccessType(t.tsTypeReference(t.identifier(createInputTypeName)), t.tsLiteralType(t.stringLiteral(singularName)));
|
|
454
|
+
const argsType = (sel) => t.tsTypeReference(t.identifier('BulkInsertArgs'), t.tsTypeParameterInstantiation([sel, dataType()]));
|
|
455
|
+
const retType = (sel) => t.tsTypeAnnotation(t.tsTypeReference(t.identifier('QueryBuilder'), t.tsTypeParameterInstantiation([
|
|
456
|
+
t.tsTypeReference(t.identifier('BulkMutationResult'), t.tsTypeParameterInstantiation([
|
|
457
|
+
t.tsTypeReference(t.identifier('InferSelectResult'), t.tsTypeParameterInstantiation([
|
|
458
|
+
t.tsTypeReference(t.identifier(relationTypeName)),
|
|
459
|
+
sel,
|
|
460
|
+
])),
|
|
461
|
+
])),
|
|
462
|
+
])));
|
|
463
|
+
const implParam = t.identifier('args');
|
|
464
|
+
implParam.typeAnnotation = t.tsTypeAnnotation(t.tsIntersectionType([
|
|
465
|
+
argsType(sRef()),
|
|
466
|
+
t.tsTypeLiteral([requiredSelectProp()]),
|
|
467
|
+
strictSelectGuard(selectTypeName),
|
|
468
|
+
]));
|
|
469
|
+
const selectExpr = t.memberExpression(t.identifier('args'), t.identifier('select'));
|
|
470
|
+
const bodyArgs = [
|
|
471
|
+
t.stringLiteral(typeName),
|
|
472
|
+
t.stringLiteral(bulkInsertMutationName),
|
|
473
|
+
selectExpr,
|
|
474
|
+
t.memberExpression(t.identifier('args'), t.identifier('data')),
|
|
475
|
+
t.stringLiteral(bulkInsertInputTypeName),
|
|
476
|
+
t.memberExpression(t.identifier('args'), t.identifier('onConflict')),
|
|
477
|
+
t.identifier('connectionFieldsMap'),
|
|
478
|
+
];
|
|
479
|
+
classBody.push(createClassMethod('bulkCreate', createTypeParam(selectTypeName), [implParam], retType(sRef()), buildMethodBody('buildBulkInsertDocument', bodyArgs, 'mutation', typeName, bulkInsertMutationName)));
|
|
480
|
+
}
|
|
481
|
+
// ── bulkUpsert ─────────────────────────────────────────────────────────
|
|
482
|
+
if (bulkUpsertMutationName) {
|
|
483
|
+
const bulkUpsertInputTypeName = `BulkUpsert${typeName}Input`;
|
|
484
|
+
const dataType = () => t.tsIndexedAccessType(t.tsTypeReference(t.identifier(createInputTypeName)), t.tsLiteralType(t.stringLiteral(singularName)));
|
|
485
|
+
const argsType = (sel) => t.tsTypeReference(t.identifier('BulkUpsertArgs'), t.tsTypeParameterInstantiation([sel, dataType()]));
|
|
486
|
+
const retType = (sel) => t.tsTypeAnnotation(t.tsTypeReference(t.identifier('QueryBuilder'), t.tsTypeParameterInstantiation([
|
|
487
|
+
t.tsTypeReference(t.identifier('BulkMutationResult'), t.tsTypeParameterInstantiation([
|
|
488
|
+
t.tsTypeReference(t.identifier('InferSelectResult'), t.tsTypeParameterInstantiation([
|
|
489
|
+
t.tsTypeReference(t.identifier(relationTypeName)),
|
|
490
|
+
sel,
|
|
491
|
+
])),
|
|
492
|
+
])),
|
|
493
|
+
])));
|
|
494
|
+
const implParam = t.identifier('args');
|
|
495
|
+
implParam.typeAnnotation = t.tsTypeAnnotation(t.tsIntersectionType([
|
|
496
|
+
argsType(sRef()),
|
|
497
|
+
t.tsTypeLiteral([requiredSelectProp()]),
|
|
498
|
+
strictSelectGuard(selectTypeName),
|
|
499
|
+
]));
|
|
500
|
+
const selectExpr = t.memberExpression(t.identifier('args'), t.identifier('select'));
|
|
501
|
+
const bodyArgs = [
|
|
502
|
+
t.stringLiteral(typeName),
|
|
503
|
+
t.stringLiteral(bulkUpsertMutationName),
|
|
504
|
+
selectExpr,
|
|
505
|
+
t.memberExpression(t.identifier('args'), t.identifier('data')),
|
|
506
|
+
t.stringLiteral(bulkUpsertInputTypeName),
|
|
507
|
+
t.memberExpression(t.identifier('args'), t.identifier('onConflict')),
|
|
508
|
+
t.identifier('connectionFieldsMap'),
|
|
509
|
+
];
|
|
510
|
+
classBody.push(createClassMethod('bulkUpsert', createTypeParam(selectTypeName), [implParam], retType(sRef()), buildMethodBody('buildBulkUpsertDocument', bodyArgs, 'mutation', typeName, bulkUpsertMutationName)));
|
|
511
|
+
}
|
|
512
|
+
// ── bulkUpdate ─────────────────────────────────────────────────────────
|
|
513
|
+
if (bulkUpdateMutationName) {
|
|
514
|
+
const bulkUpdateInputTypeName = `BulkUpdate${typeName}Input`;
|
|
515
|
+
const argsType = (sel) => t.tsTypeReference(t.identifier('BulkUpdateArgs'), t.tsTypeParameterInstantiation([
|
|
516
|
+
sel,
|
|
517
|
+
t.tsTypeReference(t.identifier(whereTypeName)),
|
|
518
|
+
t.tsTypeReference(t.identifier(patchTypeName)),
|
|
519
|
+
]));
|
|
520
|
+
const retType = (sel) => t.tsTypeAnnotation(t.tsTypeReference(t.identifier('QueryBuilder'), t.tsTypeParameterInstantiation([
|
|
521
|
+
t.tsTypeReference(t.identifier('BulkMutationResult'), t.tsTypeParameterInstantiation([
|
|
522
|
+
t.tsTypeReference(t.identifier('InferSelectResult'), t.tsTypeParameterInstantiation([
|
|
523
|
+
t.tsTypeReference(t.identifier(relationTypeName)),
|
|
524
|
+
sel,
|
|
525
|
+
])),
|
|
526
|
+
])),
|
|
527
|
+
])));
|
|
528
|
+
const implParam = t.identifier('args');
|
|
529
|
+
implParam.typeAnnotation = t.tsTypeAnnotation(t.tsIntersectionType([
|
|
530
|
+
argsType(sRef()),
|
|
531
|
+
t.tsTypeLiteral([requiredSelectProp()]),
|
|
532
|
+
strictSelectGuard(selectTypeName),
|
|
533
|
+
]));
|
|
534
|
+
const selectExpr = t.memberExpression(t.identifier('args'), t.identifier('select'));
|
|
535
|
+
const bodyArgs = [
|
|
536
|
+
t.stringLiteral(typeName),
|
|
537
|
+
t.stringLiteral(bulkUpdateMutationName),
|
|
538
|
+
selectExpr,
|
|
539
|
+
t.memberExpression(t.identifier('args'), t.identifier('where')),
|
|
540
|
+
t.memberExpression(t.identifier('args'), t.identifier('data')),
|
|
541
|
+
t.stringLiteral(bulkUpdateInputTypeName),
|
|
542
|
+
t.identifier('connectionFieldsMap'),
|
|
543
|
+
];
|
|
544
|
+
classBody.push(createClassMethod('bulkUpdate', createTypeParam(selectTypeName), [implParam], retType(sRef()), buildMethodBody('buildBulkUpdateDocument', bodyArgs, 'mutation', typeName, bulkUpdateMutationName)));
|
|
545
|
+
}
|
|
546
|
+
// ── bulkDelete ─────────────────────────────────────────────────────────
|
|
547
|
+
if (bulkDeleteMutationName) {
|
|
548
|
+
const bulkDeleteInputTypeName = `BulkDelete${typeName}Input`;
|
|
549
|
+
const argsType = (sel) => t.tsTypeReference(t.identifier('BulkDeleteArgs'), t.tsTypeParameterInstantiation([
|
|
550
|
+
sel,
|
|
551
|
+
t.tsTypeReference(t.identifier(whereTypeName)),
|
|
552
|
+
]));
|
|
553
|
+
const retType = (sel) => t.tsTypeAnnotation(t.tsTypeReference(t.identifier('QueryBuilder'), t.tsTypeParameterInstantiation([
|
|
554
|
+
t.tsTypeReference(t.identifier('BulkMutationResult'), t.tsTypeParameterInstantiation([
|
|
555
|
+
t.tsTypeReference(t.identifier('InferSelectResult'), t.tsTypeParameterInstantiation([
|
|
556
|
+
t.tsTypeReference(t.identifier(relationTypeName)),
|
|
557
|
+
sel,
|
|
558
|
+
])),
|
|
559
|
+
])),
|
|
560
|
+
])));
|
|
561
|
+
const implParam = t.identifier('args');
|
|
562
|
+
implParam.typeAnnotation = t.tsTypeAnnotation(t.tsIntersectionType([
|
|
563
|
+
argsType(sRef()),
|
|
564
|
+
t.tsTypeLiteral([requiredSelectProp()]),
|
|
565
|
+
strictSelectGuard(selectTypeName),
|
|
566
|
+
]));
|
|
567
|
+
const selectExpr = t.memberExpression(t.identifier('args'), t.identifier('select'));
|
|
568
|
+
const bodyArgs = [
|
|
569
|
+
t.stringLiteral(typeName),
|
|
570
|
+
t.stringLiteral(bulkDeleteMutationName),
|
|
571
|
+
selectExpr,
|
|
572
|
+
t.memberExpression(t.identifier('args'), t.identifier('where')),
|
|
573
|
+
t.stringLiteral(bulkDeleteInputTypeName),
|
|
574
|
+
t.identifier('connectionFieldsMap'),
|
|
575
|
+
];
|
|
576
|
+
classBody.push(createClassMethod('bulkDelete', createTypeParam(selectTypeName), [implParam], retType(sRef()), buildMethodBody('buildBulkDeleteDocument', bodyArgs, 'mutation', typeName, bulkDeleteMutationName)));
|
|
577
|
+
}
|
|
416
578
|
// ── M:N add/remove methods ────────────────────────────────────────────
|
|
417
579
|
for (const rel of m2nRels) {
|
|
418
580
|
if (!rel.fieldName)
|
|
@@ -167,9 +167,10 @@ export interface FindManyArgs<TSelect, TWhere, TOrderBy> {
|
|
|
167
167
|
/**
|
|
168
168
|
* Arguments for findFirst/findUnique operations
|
|
169
169
|
*/
|
|
170
|
-
export interface FindFirstArgs<TSelect, TWhere> {
|
|
170
|
+
export interface FindFirstArgs<TSelect, TWhere, TOrderBy> {
|
|
171
171
|
select?: TSelect;
|
|
172
172
|
where?: TWhere;
|
|
173
|
+
orderBy?: TOrderBy[];
|
|
173
174
|
}
|
|
174
175
|
/**
|
|
175
176
|
* Arguments for create operations
|
|
@@ -433,7 +433,7 @@ export function generateSingleQueryHook(table, options = {}) {
|
|
|
433
433
|
t.tsPropertySignature(t.identifier(pkFieldName), t.tsTypeAnnotation(pkTsType)),
|
|
434
434
|
t.tsPropertySignature(t.identifier('selection'), t.tsTypeAnnotation(selectionConfigType(typeRef(selectTypeName)))),
|
|
435
435
|
];
|
|
436
|
-
statements.push(exportAsyncFunction(fetchFnName, null, [createFunctionParam('params', t.tsTypeLiteral(fImplProps))], fBody));
|
|
436
|
+
statements.push(exportAsyncFunction(fetchFnName, null, [createFunctionParam('params', t.tsTypeLiteral(fImplProps))], fBody, typeRef('Promise', [t.tsAnyKeyword()])));
|
|
437
437
|
}
|
|
438
438
|
// Prefetch function
|
|
439
439
|
if (reactQueryEnabled) {
|
|
@@ -101,6 +101,14 @@ export declare function getUpdateMutationName(table: Table): string;
|
|
|
101
101
|
* Get the GraphQL mutation name for deleting
|
|
102
102
|
*/
|
|
103
103
|
export declare function getDeleteMutationName(table: Table): string;
|
|
104
|
+
export declare function getBulkCreateMutationHookName(table: Table): string;
|
|
105
|
+
export declare function getBulkUpsertMutationHookName(table: Table): string;
|
|
106
|
+
export declare function getBulkUpdateMutationHookName(table: Table): string;
|
|
107
|
+
export declare function getBulkDeleteMutationHookName(table: Table): string;
|
|
108
|
+
export declare function getBulkCreateMutationFileName(table: Table): string;
|
|
109
|
+
export declare function getBulkUpsertMutationFileName(table: Table): string;
|
|
110
|
+
export declare function getBulkUpdateMutationFileName(table: Table): string;
|
|
111
|
+
export declare function getBulkDeleteMutationFileName(table: Table): string;
|
|
104
112
|
/**
|
|
105
113
|
* Get PostGraphile filter type name
|
|
106
114
|
* e.g., "CarFilter"
|
|
@@ -154,6 +154,37 @@ export function getDeleteMutationName(table) {
|
|
|
154
154
|
return table.query?.delete || `delete${table.name}`;
|
|
155
155
|
}
|
|
156
156
|
// ============================================================================
|
|
157
|
+
// Bulk mutation naming helpers
|
|
158
|
+
// ============================================================================
|
|
159
|
+
export function getBulkCreateMutationHookName(table) {
|
|
160
|
+
const { typeName } = getTableNames(table);
|
|
161
|
+
return `useBulkCreate${typeName}Mutation`;
|
|
162
|
+
}
|
|
163
|
+
export function getBulkUpsertMutationHookName(table) {
|
|
164
|
+
const { typeName } = getTableNames(table);
|
|
165
|
+
return `useBulkUpsert${typeName}Mutation`;
|
|
166
|
+
}
|
|
167
|
+
export function getBulkUpdateMutationHookName(table) {
|
|
168
|
+
const { typeName } = getTableNames(table);
|
|
169
|
+
return `useBulkUpdate${typeName}Mutation`;
|
|
170
|
+
}
|
|
171
|
+
export function getBulkDeleteMutationHookName(table) {
|
|
172
|
+
const { typeName } = getTableNames(table);
|
|
173
|
+
return `useBulkDelete${typeName}Mutation`;
|
|
174
|
+
}
|
|
175
|
+
export function getBulkCreateMutationFileName(table) {
|
|
176
|
+
return `${getBulkCreateMutationHookName(table)}.ts`;
|
|
177
|
+
}
|
|
178
|
+
export function getBulkUpsertMutationFileName(table) {
|
|
179
|
+
return `${getBulkUpsertMutationHookName(table)}.ts`;
|
|
180
|
+
}
|
|
181
|
+
export function getBulkUpdateMutationFileName(table) {
|
|
182
|
+
return `${getBulkUpdateMutationHookName(table)}.ts`;
|
|
183
|
+
}
|
|
184
|
+
export function getBulkDeleteMutationFileName(table) {
|
|
185
|
+
return `${getBulkDeleteMutationHookName(table)}.ts`;
|
|
186
|
+
}
|
|
187
|
+
// ============================================================================
|
|
157
188
|
// Type names
|
|
158
189
|
// ============================================================================
|
|
159
190
|
/**
|
package/esm/types/schema.d.ts
CHANGED
|
@@ -85,6 +85,14 @@ export interface TableQueryNames {
|
|
|
85
85
|
delete: string | null;
|
|
86
86
|
/** Patch field name in update mutation input (e.g., "userPatch" for UpdateUserInput) */
|
|
87
87
|
patchFieldName?: string;
|
|
88
|
+
/** Bulk insert mutation name (e.g., "bulkCreateUsers") */
|
|
89
|
+
bulkInsert?: string | null;
|
|
90
|
+
/** Bulk upsert mutation name (e.g., "bulkUpsertUsers") */
|
|
91
|
+
bulkUpsert?: string | null;
|
|
92
|
+
/** Bulk update mutation name (e.g., "bulkUpdateUsers") */
|
|
93
|
+
bulkUpdate?: string | null;
|
|
94
|
+
/** Bulk delete mutation name (e.g., "bulkDeleteUsers") */
|
|
95
|
+
bulkDelete?: string | null;
|
|
88
96
|
}
|
|
89
97
|
/**
|
|
90
98
|
* Table constraints
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/graphql-codegen",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.41.0",
|
|
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.29.1",
|
|
58
58
|
"@babel/types": "^7.29.0",
|
|
59
|
-
"@constructive-io/graphql-query": "^3.
|
|
59
|
+
"@constructive-io/graphql-query": "^3.24.0",
|
|
60
60
|
"@constructive-io/graphql-types": "^3.9.1",
|
|
61
61
|
"@inquirerer/utils": "^3.3.5",
|
|
62
62
|
"@pgpmjs/core": "^6.17.1",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"deepmerge": "^4.3.1",
|
|
65
65
|
"find-and-require-package-json": "^0.9.1",
|
|
66
66
|
"gql-ast": "^3.9.1",
|
|
67
|
-
"graphile-schema": "^1.19.
|
|
67
|
+
"graphile-schema": "^1.19.4",
|
|
68
68
|
"graphql": "16.13.0",
|
|
69
69
|
"inflekt": "^0.7.1",
|
|
70
70
|
"inquirerer": "^4.7.0",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"tsx": "^4.21.0",
|
|
101
101
|
"typescript": "^5.9.3"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "70f9d2052fe9218c65b82e896d1660d4dc6a51c8"
|
|
104
104
|
}
|
package/types/schema.d.ts
CHANGED
|
@@ -85,6 +85,14 @@ export interface TableQueryNames {
|
|
|
85
85
|
delete: string | null;
|
|
86
86
|
/** Patch field name in update mutation input (e.g., "userPatch" for UpdateUserInput) */
|
|
87
87
|
patchFieldName?: string;
|
|
88
|
+
/** Bulk insert mutation name (e.g., "bulkCreateUsers") */
|
|
89
|
+
bulkInsert?: string | null;
|
|
90
|
+
/** Bulk upsert mutation name (e.g., "bulkUpsertUsers") */
|
|
91
|
+
bulkUpsert?: string | null;
|
|
92
|
+
/** Bulk update mutation name (e.g., "bulkUpdateUsers") */
|
|
93
|
+
bulkUpdate?: string | null;
|
|
94
|
+
/** Bulk delete mutation name (e.g., "bulkDeleteUsers") */
|
|
95
|
+
bulkDelete?: string | null;
|
|
88
96
|
}
|
|
89
97
|
/**
|
|
90
98
|
* Table constraints
|