From 6785de272bd55d489ab91a8d5fe630f274ce9b45 Mon Sep 17 00:00:00 2001 From: yyyyaaa Date: Mon, 19 Jan 2026 16:38:03 +0700 Subject: [PATCH 1/2] fix(codegen): use correct deleted{Entity}NodeId field in delete mutations --- .../react-query-hooks.test.ts.snap | 12 ++--- graphql/codegen/src/cli/codegen/gql-ast.ts | 16 +++++-- graphql/codegen/src/cli/codegen/index.ts | 1 + graphql/codegen/src/cli/codegen/mutations.ts | 26 ++++++++--- graphql/codegen/src/cli/codegen/utils.ts | 46 +++++++++++++++++++ 5 files changed, 86 insertions(+), 15 deletions(-) diff --git a/graphql/codegen/src/__tests__/codegen/__snapshots__/react-query-hooks.test.ts.snap b/graphql/codegen/src/__tests__/codegen/__snapshots__/react-query-hooks.test.ts.snap index 1fa921534..6d2071bfd 100644 --- a/graphql/codegen/src/__tests__/codegen/__snapshots__/react-query-hooks.test.ts.snap +++ b/graphql/codegen/src/__tests__/codegen/__snapshots__/react-query-hooks.test.ts.snap @@ -770,7 +770,7 @@ export const deleteUserMutationDocument = \` mutation DeleteUserMutation($input: DeleteUserInput!) { deleteUser(input: $input) { clientMutationId - deletedId + deletedUserNodeId } } \`; @@ -782,7 +782,7 @@ export interface DeleteUserMutationVariables { export interface DeleteUserMutationResult { deleteUser: { clientMutationId: string | null; - deletedId: string | null; + deletedUserNodeId: string | null; }; } /** @@ -834,7 +834,7 @@ export const deletePostMutationDocument = \` mutation DeletePostMutation($input: DeletePostInput!) { deletePost(input: $input) { clientMutationId - deletedId + deletedPostNodeId } } \`; @@ -846,7 +846,7 @@ export interface DeletePostMutationVariables { export interface DeletePostMutationResult { deletePost: { clientMutationId: string | null; - deletedId: string | null; + deletedPostNodeId: string | null; }; } /** @@ -895,7 +895,7 @@ export const deleteUserMutationDocument = \` mutation DeleteUserMutation($input: DeleteUserInput!) { deleteUser(input: $input) { clientMutationId - deletedId + deletedUserNodeId } } \`; @@ -907,7 +907,7 @@ export interface DeleteUserMutationVariables { export interface DeleteUserMutationResult { deleteUser: { clientMutationId: string | null; - deletedId: string | null; + deletedUserNodeId: string | null; }; } /** diff --git a/graphql/codegen/src/cli/codegen/gql-ast.ts b/graphql/codegen/src/cli/codegen/gql-ast.ts index ec2c13aac..8dc14c157 100644 --- a/graphql/codegen/src/cli/codegen/gql-ast.ts +++ b/graphql/codegen/src/cli/codegen/gql-ast.ts @@ -12,7 +12,7 @@ import type { ArgumentNode, VariableDefinitionNode, } from 'graphql'; -import type { CleanTable, CleanField } from '../../types/schema'; +import type { CleanTable, CleanField, TypeRegistry } from '../../types/schema'; import { getTableNames, getAllRowsQueryName, @@ -26,6 +26,8 @@ import { getScalarFields, getPrimaryKeyInfo, ucFirst, + getDeletedNodeIdFieldName, + getDeletePayloadTypeName, } from './utils'; @@ -345,16 +347,24 @@ export function buildUpdateMutationAST(config: UpdateMutationConfig): DocumentNo export interface DeleteMutationConfig { table: CleanTable; + /** TypeRegistry for looking up actual payload field names from schema */ + typeRegistry?: TypeRegistry; } /** * Build a delete mutation AST for a table */ export function buildDeleteMutationAST(config: DeleteMutationConfig): DocumentNode { - const { table } = config; + const { table, typeRegistry } = config; const { typeName } = getTableNames(table); const mutationName = getDeleteMutationName(table); const inputTypeName = `Delete${typeName}Input`; + const deletePayloadTypeName = getDeletePayloadTypeName(table); + const deletedNodeIdFieldName = getDeletedNodeIdFieldName( + typeRegistry, + deletePayloadTypeName, + typeName + ); // Variable definitions const variableDefinitions: VariableDefinitionNode[] = [ @@ -383,7 +393,7 @@ export function buildDeleteMutationAST(config: DeleteMutationConfig): DocumentNo selectionSet: t.selectionSet({ selections: [ t.field({ name: 'clientMutationId' }), - t.field({ name: 'deletedId' }), + t.field({ name: deletedNodeIdFieldName }), ], }), }), diff --git a/graphql/codegen/src/cli/codegen/index.ts b/graphql/codegen/src/cli/codegen/index.ts index 8778b7406..0cb931a2d 100644 --- a/graphql/codegen/src/cli/codegen/index.ts +++ b/graphql/codegen/src/cli/codegen/index.ts @@ -256,6 +256,7 @@ export function generate(options: GenerateOptions): GenerateResult { useCentralizedKeys, hasRelationships, tableTypeNames, + typeRegistry: customOperations?.typeRegistry, }); for (const hook of mutationHooks) { files.push({ diff --git a/graphql/codegen/src/cli/codegen/mutations.ts b/graphql/codegen/src/cli/codegen/mutations.ts index 11596b3fe..d7df7362b 100644 --- a/graphql/codegen/src/cli/codegen/mutations.ts +++ b/graphql/codegen/src/cli/codegen/mutations.ts @@ -7,7 +7,7 @@ * useUpdateCarMutation.ts * useDeleteCarMutation.ts */ -import type { CleanTable } from '../../types/schema'; +import type { CleanTable, TypeRegistry } from '../../types/schema'; import * as t from '@babel/types'; import { generateCode, addJSDocComment, typedParam, createTypedCallExpression } from './babel-ast'; import { @@ -33,6 +33,8 @@ import { ucFirst, lcFirst, getGeneratedFileHeader, + getDeletedNodeIdFieldName, + getDeletePayloadTypeName, } from './utils'; function isAutoGeneratedField(fieldName: string, pkFieldNames: Set): boolean { @@ -58,6 +60,8 @@ export interface MutationGeneratorOptions { hasRelationships?: boolean; /** All table type names for determining which types to import from types.ts vs schema-types.ts */ tableTypeNames?: Set; + /** TypeRegistry for looking up actual payload field names from schema introspection */ + typeRegistry?: TypeRegistry; } export function generateCreateMutationHook( @@ -688,6 +692,7 @@ export function generateDeleteMutationHook( reactQueryEnabled = true, useCentralizedKeys = true, hasRelationships = false, + typeRegistry, } = options; if (!reactQueryEnabled) { @@ -708,7 +713,15 @@ export function generateDeleteMutationHook( const pkFields = getPrimaryKeyInfo(table); const pkField = pkFields[0]; - const mutationAST = buildDeleteMutationAST({ table }); + // Get the correct deletedNodeId field name from schema or convention + const deletePayloadTypeName = getDeletePayloadTypeName(table); + const deletedNodeIdFieldName = getDeletedNodeIdFieldName( + typeRegistry, + deletePayloadTypeName, + typeName + ); + + const mutationAST = buildDeleteMutationAST({ table, typeRegistry }); const mutationDocument = printGraphQL(mutationAST); const statements: t.Statement[] = []; @@ -792,9 +805,10 @@ export function generateDeleteMutationHook( ); statements.push(t.exportNamedDeclaration(variablesInterface)); - const deletedPkProp = t.tsPropertySignature( - t.identifier(`deleted${ucFirst(pkField.name)}`), - t.tsTypeAnnotation(t.tsUnionType([pkTypeAnnotation, t.tsNullKeyword()])) + // Use the schema-inferred field name for the deleted node ID + const deletedNodeIdProp = t.tsPropertySignature( + t.identifier(deletedNodeIdFieldName), + t.tsTypeAnnotation(t.tsUnionType([t.tsStringKeyword(), t.tsNullKeyword()])) ); const clientMutationIdProp = t.tsPropertySignature( t.identifier('clientMutationId'), @@ -804,7 +818,7 @@ export function generateDeleteMutationHook( const resultInterfaceBody = t.tsInterfaceBody([ t.tsPropertySignature( t.identifier(mutationName), - t.tsTypeAnnotation(t.tsTypeLiteral([clientMutationIdProp, deletedPkProp])) + t.tsTypeAnnotation(t.tsTypeLiteral([clientMutationIdProp, deletedNodeIdProp])) ), ]); const resultInterface = t.tsInterfaceDeclaration( diff --git a/graphql/codegen/src/cli/codegen/utils.ts b/graphql/codegen/src/cli/codegen/utils.ts index dc46b8703..0af9d7d06 100644 --- a/graphql/codegen/src/cli/codegen/utils.ts +++ b/graphql/codegen/src/cli/codegen/utils.ts @@ -5,6 +5,7 @@ import type { CleanTable, CleanField, CleanFieldType, + TypeRegistry, } from '../../types/schema'; import { scalarToTsType, scalarToFilterType } from './scalars'; import { pluralize } from 'inflekt'; @@ -412,6 +413,51 @@ export function getQueryKeyPrefix(table: CleanTable): string { return lcFirst(table.name); } +// ============================================================================ +// Delete mutation helpers +// ============================================================================ + +/** + * Get the deleted node ID field name from a delete mutation payload. + * + * PostGraphile generates delete payloads with a field following the pattern + * `deleted{EntityName}NodeId`. This function looks up the actual field name + * from the TypeRegistry if available, or falls back to the convention. + * + * @param typeRegistry - The type registry from schema introspection + * @param deletePayloadTypeName - The payload type name (e.g., "DeleteUserPayload") + * @param entityTypeName - The entity type name (e.g., "User") for fallback + * @returns The field name (e.g., "deletedUserNodeId") + */ +export function getDeletedNodeIdFieldName( + typeRegistry: TypeRegistry | undefined, + deletePayloadTypeName: string, + entityTypeName: string +): string { + if (typeRegistry) { + const payloadType = typeRegistry.get(deletePayloadTypeName); + if (payloadType?.fields) { + // Find the field that matches the pattern deleted*NodeId + const deletedNodeIdField = payloadType.fields.find( + (f) => f.name.startsWith('deleted') && f.name.endsWith('NodeId') + ); + if (deletedNodeIdField) { + return deletedNodeIdField.name; + } + } + } + // Fallback to PostGraphile naming convention + return `deleted${entityTypeName}NodeId`; +} + +/** + * Get the delete payload type name for a table. + * Uses inflection if available, otherwise falls back to convention. + */ +export function getDeletePayloadTypeName(table: CleanTable): string { + return table.inflection?.deletePayloadType || `Delete${table.name}Payload`; +} + // ============================================================================ // Code generation helpers // ============================================================================ From 63929a2421e6fcd68fb107ef4d45a30359e6af4f Mon Sep 17 00:00:00 2001 From: yyyyaaa Date: Tue, 20 Jan 2026 11:25:14 +0700 Subject: [PATCH 2/2] fix(codegen): remove deleted{Entity}NodeId field from delete mutations Remove the deletedNodeId field from generated delete mutations as it's no longer used due to internal backend concerns. The field still exists in the GraphQL schema but is no longer selected in generated code. Changes: - Remove deletedNodeIdFieldName from mutation selection in gql-ast.ts - Remove deletedNodeIdProp from result interface in mutations.ts - Remove getDeletedNodeIdFieldName and getDeletePayloadTypeName helpers - Remove typeRegistry parameter from mutation generation - Update test snapshots --- .../client-generator.test.ts.snap | 2 +- .../input-types-generator.test.ts.snap | 2 +- .../model-generator.test.ts.snap | 2 +- .../query-keys-factory.test.ts.snap | 2 +- .../react-query-hooks.test.ts.snap | 8 +--- .../schema-types-generator.test.ts.snap | 2 +- graphql/codegen/src/cli/codegen/gql-ast.ts | 15 +----- graphql/codegen/src/cli/codegen/index.ts | 1 - graphql/codegen/src/cli/codegen/mutations.ts | 24 ++-------- graphql/codegen/src/cli/codegen/utils.ts | 46 ------------------- 10 files changed, 11 insertions(+), 93 deletions(-) diff --git a/graphql/codegen/src/__tests__/codegen/__snapshots__/client-generator.test.ts.snap b/graphql/codegen/src/__tests__/codegen/__snapshots__/client-generator.test.ts.snap index 2581ad40f..e9a299087 100644 --- a/graphql/codegen/src/__tests__/codegen/__snapshots__/client-generator.test.ts.snap +++ b/graphql/codegen/src/__tests__/codegen/__snapshots__/client-generator.test.ts.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`client-generator generateCreateClientFile generates createClient factory with models 1`] = ` "/** diff --git a/graphql/codegen/src/__tests__/codegen/__snapshots__/input-types-generator.test.ts.snap b/graphql/codegen/src/__tests__/codegen/__snapshots__/input-types-generator.test.ts.snap index 9fa5733d5..523156dd3 100644 --- a/graphql/codegen/src/__tests__/codegen/__snapshots__/input-types-generator.test.ts.snap +++ b/graphql/codegen/src/__tests__/codegen/__snapshots__/input-types-generator.test.ts.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`generateInputTypesFile generates complete types file for multiple tables with relations 1`] = ` "/** diff --git a/graphql/codegen/src/__tests__/codegen/__snapshots__/model-generator.test.ts.snap b/graphql/codegen/src/__tests__/codegen/__snapshots__/model-generator.test.ts.snap index db345a4e2..dc51d712f 100644 --- a/graphql/codegen/src/__tests__/codegen/__snapshots__/model-generator.test.ts.snap +++ b/graphql/codegen/src/__tests__/codegen/__snapshots__/model-generator.test.ts.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`model-generator generates model with all CRUD methods 1`] = ` "/** diff --git a/graphql/codegen/src/__tests__/codegen/__snapshots__/query-keys-factory.test.ts.snap b/graphql/codegen/src/__tests__/codegen/__snapshots__/query-keys-factory.test.ts.snap index 9d6e45077..6bf8d8eb1 100644 --- a/graphql/codegen/src/__tests__/codegen/__snapshots__/query-keys-factory.test.ts.snap +++ b/graphql/codegen/src/__tests__/codegen/__snapshots__/query-keys-factory.test.ts.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`generateInvalidationFile generates invalidation helpers for a single table without relationships 1`] = ` "/** diff --git a/graphql/codegen/src/__tests__/codegen/__snapshots__/react-query-hooks.test.ts.snap b/graphql/codegen/src/__tests__/codegen/__snapshots__/react-query-hooks.test.ts.snap index 6d2071bfd..efafdb00e 100644 --- a/graphql/codegen/src/__tests__/codegen/__snapshots__/react-query-hooks.test.ts.snap +++ b/graphql/codegen/src/__tests__/codegen/__snapshots__/react-query-hooks.test.ts.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`Barrel File Generators generateCustomMutationsBarrel generates custom mutations barrel 1`] = ` "/** @@ -770,7 +770,6 @@ export const deleteUserMutationDocument = \` mutation DeleteUserMutation($input: DeleteUserInput!) { deleteUser(input: $input) { clientMutationId - deletedUserNodeId } } \`; @@ -782,7 +781,6 @@ export interface DeleteUserMutationVariables { export interface DeleteUserMutationResult { deleteUser: { clientMutationId: string | null; - deletedUserNodeId: string | null; }; } /** @@ -834,7 +832,6 @@ export const deletePostMutationDocument = \` mutation DeletePostMutation($input: DeletePostInput!) { deletePost(input: $input) { clientMutationId - deletedPostNodeId } } \`; @@ -846,7 +843,6 @@ export interface DeletePostMutationVariables { export interface DeletePostMutationResult { deletePost: { clientMutationId: string | null; - deletedPostNodeId: string | null; }; } /** @@ -895,7 +891,6 @@ export const deleteUserMutationDocument = \` mutation DeleteUserMutation($input: DeleteUserInput!) { deleteUser(input: $input) { clientMutationId - deletedUserNodeId } } \`; @@ -907,7 +902,6 @@ export interface DeleteUserMutationVariables { export interface DeleteUserMutationResult { deleteUser: { clientMutationId: string | null; - deletedUserNodeId: string | null; }; } /** diff --git a/graphql/codegen/src/__tests__/codegen/__snapshots__/schema-types-generator.test.ts.snap b/graphql/codegen/src/__tests__/codegen/__snapshots__/schema-types-generator.test.ts.snap index f3111ec74..e7d4d48d2 100644 --- a/graphql/codegen/src/__tests__/codegen/__snapshots__/schema-types-generator.test.ts.snap +++ b/graphql/codegen/src/__tests__/codegen/__snapshots__/schema-types-generator.test.ts.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`schema-types-generator generates enum types as string unions 1`] = ` "/** diff --git a/graphql/codegen/src/cli/codegen/gql-ast.ts b/graphql/codegen/src/cli/codegen/gql-ast.ts index 8dc14c157..612db24a0 100644 --- a/graphql/codegen/src/cli/codegen/gql-ast.ts +++ b/graphql/codegen/src/cli/codegen/gql-ast.ts @@ -12,7 +12,7 @@ import type { ArgumentNode, VariableDefinitionNode, } from 'graphql'; -import type { CleanTable, CleanField, TypeRegistry } from '../../types/schema'; +import type { CleanTable, CleanField } from '../../types/schema'; import { getTableNames, getAllRowsQueryName, @@ -26,8 +26,6 @@ import { getScalarFields, getPrimaryKeyInfo, ucFirst, - getDeletedNodeIdFieldName, - getDeletePayloadTypeName, } from './utils'; @@ -347,24 +345,16 @@ export function buildUpdateMutationAST(config: UpdateMutationConfig): DocumentNo export interface DeleteMutationConfig { table: CleanTable; - /** TypeRegistry for looking up actual payload field names from schema */ - typeRegistry?: TypeRegistry; } /** * Build a delete mutation AST for a table */ export function buildDeleteMutationAST(config: DeleteMutationConfig): DocumentNode { - const { table, typeRegistry } = config; + const { table } = config; const { typeName } = getTableNames(table); const mutationName = getDeleteMutationName(table); const inputTypeName = `Delete${typeName}Input`; - const deletePayloadTypeName = getDeletePayloadTypeName(table); - const deletedNodeIdFieldName = getDeletedNodeIdFieldName( - typeRegistry, - deletePayloadTypeName, - typeName - ); // Variable definitions const variableDefinitions: VariableDefinitionNode[] = [ @@ -393,7 +383,6 @@ export function buildDeleteMutationAST(config: DeleteMutationConfig): DocumentNo selectionSet: t.selectionSet({ selections: [ t.field({ name: 'clientMutationId' }), - t.field({ name: deletedNodeIdFieldName }), ], }), }), diff --git a/graphql/codegen/src/cli/codegen/index.ts b/graphql/codegen/src/cli/codegen/index.ts index 0cb931a2d..8778b7406 100644 --- a/graphql/codegen/src/cli/codegen/index.ts +++ b/graphql/codegen/src/cli/codegen/index.ts @@ -256,7 +256,6 @@ export function generate(options: GenerateOptions): GenerateResult { useCentralizedKeys, hasRelationships, tableTypeNames, - typeRegistry: customOperations?.typeRegistry, }); for (const hook of mutationHooks) { files.push({ diff --git a/graphql/codegen/src/cli/codegen/mutations.ts b/graphql/codegen/src/cli/codegen/mutations.ts index d7df7362b..0a3a75227 100644 --- a/graphql/codegen/src/cli/codegen/mutations.ts +++ b/graphql/codegen/src/cli/codegen/mutations.ts @@ -7,7 +7,7 @@ * useUpdateCarMutation.ts * useDeleteCarMutation.ts */ -import type { CleanTable, TypeRegistry } from '../../types/schema'; +import type { CleanTable } from '../../types/schema'; import * as t from '@babel/types'; import { generateCode, addJSDocComment, typedParam, createTypedCallExpression } from './babel-ast'; import { @@ -33,8 +33,6 @@ import { ucFirst, lcFirst, getGeneratedFileHeader, - getDeletedNodeIdFieldName, - getDeletePayloadTypeName, } from './utils'; function isAutoGeneratedField(fieldName: string, pkFieldNames: Set): boolean { @@ -60,8 +58,6 @@ export interface MutationGeneratorOptions { hasRelationships?: boolean; /** All table type names for determining which types to import from types.ts vs schema-types.ts */ tableTypeNames?: Set; - /** TypeRegistry for looking up actual payload field names from schema introspection */ - typeRegistry?: TypeRegistry; } export function generateCreateMutationHook( @@ -692,7 +688,6 @@ export function generateDeleteMutationHook( reactQueryEnabled = true, useCentralizedKeys = true, hasRelationships = false, - typeRegistry, } = options; if (!reactQueryEnabled) { @@ -713,15 +708,7 @@ export function generateDeleteMutationHook( const pkFields = getPrimaryKeyInfo(table); const pkField = pkFields[0]; - // Get the correct deletedNodeId field name from schema or convention - const deletePayloadTypeName = getDeletePayloadTypeName(table); - const deletedNodeIdFieldName = getDeletedNodeIdFieldName( - typeRegistry, - deletePayloadTypeName, - typeName - ); - - const mutationAST = buildDeleteMutationAST({ table, typeRegistry }); + const mutationAST = buildDeleteMutationAST({ table }); const mutationDocument = printGraphQL(mutationAST); const statements: t.Statement[] = []; @@ -805,11 +792,6 @@ export function generateDeleteMutationHook( ); statements.push(t.exportNamedDeclaration(variablesInterface)); - // Use the schema-inferred field name for the deleted node ID - const deletedNodeIdProp = t.tsPropertySignature( - t.identifier(deletedNodeIdFieldName), - t.tsTypeAnnotation(t.tsUnionType([t.tsStringKeyword(), t.tsNullKeyword()])) - ); const clientMutationIdProp = t.tsPropertySignature( t.identifier('clientMutationId'), t.tsTypeAnnotation(t.tsUnionType([t.tsStringKeyword(), t.tsNullKeyword()])) @@ -818,7 +800,7 @@ export function generateDeleteMutationHook( const resultInterfaceBody = t.tsInterfaceBody([ t.tsPropertySignature( t.identifier(mutationName), - t.tsTypeAnnotation(t.tsTypeLiteral([clientMutationIdProp, deletedNodeIdProp])) + t.tsTypeAnnotation(t.tsTypeLiteral([clientMutationIdProp])) ), ]); const resultInterface = t.tsInterfaceDeclaration( diff --git a/graphql/codegen/src/cli/codegen/utils.ts b/graphql/codegen/src/cli/codegen/utils.ts index 0af9d7d06..dc46b8703 100644 --- a/graphql/codegen/src/cli/codegen/utils.ts +++ b/graphql/codegen/src/cli/codegen/utils.ts @@ -5,7 +5,6 @@ import type { CleanTable, CleanField, CleanFieldType, - TypeRegistry, } from '../../types/schema'; import { scalarToTsType, scalarToFilterType } from './scalars'; import { pluralize } from 'inflekt'; @@ -413,51 +412,6 @@ export function getQueryKeyPrefix(table: CleanTable): string { return lcFirst(table.name); } -// ============================================================================ -// Delete mutation helpers -// ============================================================================ - -/** - * Get the deleted node ID field name from a delete mutation payload. - * - * PostGraphile generates delete payloads with a field following the pattern - * `deleted{EntityName}NodeId`. This function looks up the actual field name - * from the TypeRegistry if available, or falls back to the convention. - * - * @param typeRegistry - The type registry from schema introspection - * @param deletePayloadTypeName - The payload type name (e.g., "DeleteUserPayload") - * @param entityTypeName - The entity type name (e.g., "User") for fallback - * @returns The field name (e.g., "deletedUserNodeId") - */ -export function getDeletedNodeIdFieldName( - typeRegistry: TypeRegistry | undefined, - deletePayloadTypeName: string, - entityTypeName: string -): string { - if (typeRegistry) { - const payloadType = typeRegistry.get(deletePayloadTypeName); - if (payloadType?.fields) { - // Find the field that matches the pattern deleted*NodeId - const deletedNodeIdField = payloadType.fields.find( - (f) => f.name.startsWith('deleted') && f.name.endsWith('NodeId') - ); - if (deletedNodeIdField) { - return deletedNodeIdField.name; - } - } - } - // Fallback to PostGraphile naming convention - return `deleted${entityTypeName}NodeId`; -} - -/** - * Get the delete payload type name for a table. - * Uses inflection if available, otherwise falls back to convention. - */ -export function getDeletePayloadTypeName(table: CleanTable): string { - return table.inflection?.deletePayloadType || `Delete${table.name}Payload`; -} - // ============================================================================ // Code generation helpers // ============================================================================