Skip to content

Conversation

@yyyyaaa
Copy link
Contributor

@yyyyaaa yyyyaaa commented Jan 19, 2026

Problem

The React Query hooks generator was producing delete mutations with a hardcoded deletedId field, but our backend convention switched to use type-specific field names. I think this is very recent?

deleted{EntityName}NodeId

Before (broken)

deleteUser(input: $input) { deletedId }

After (correct)

deleteUser(input: $input) { deletedUserNodeId }

Solution

  • Added getDeletedNodeIdFieldName() helper that infers the correct field name from the TypeRegistry (schema introspection), with fallback to PostGraphile naming convention
  • Updated buildDeleteMutationAST() and generateDeleteMutationHook() to use the inferred field name
  • Passed TypeRegistry from the codegen orchestrator to mutation generators

@yyyyaaa yyyyaaa requested a review from pyramation January 19, 2026 09:39
@pyramation
Copy link
Contributor

wait, what is deletedUserNodeId for? did the Node plugin get re-enabled?

@pyramation
Copy link
Contributor

pyramation commented Jan 19, 2026

I think this is an incorrect fix, I'm not sure we should be referencing anything NodeId or close to it

skipPlugins: [NodePlugin],

we purposefully skip the NodePlugin

Node ids are a graphql thing we don't use and they're literally useless. Maybe something broke, or we're not using graphile-settings somewhere in codegen?

https://www.graphile.org/postgraphile/node-id/

@yyyyaaa
Copy link
Contributor Author

yyyyaaa commented Jan 20, 2026

I don't know about enabling it, but this is what I see when I run latest constructive db

Screenshot 2026-01-20 at 08 05 04

@yyyyaaa
Copy link
Contributor Author

yyyyaaa commented Jan 20, 2026

literally everything that delete something mutation has it

@pyramation
Copy link
Contributor

From research:

The deletedDatabaseNodeId field is not a bug - it's expected behavior even with NodePlugin disabled.

What's happening:

In <ref_snippet file="/home/ubuntu/repos/constructive/graphile/graphile-settings/src/index.ts" lines="90-90" />, the NodePlugin is correctly being skipped:
typescript
skipPlugins: [NodePlugin],

However, the deletedDatabaseNodeId field comes from a different mechanism. PostGraphile's mutation plugins (specifically PgMutationUpdateDeletePlugin) add deletedNodeId fields to delete mutation payloads for Relay-style cache invalidation - this is separate from the NodePlugin.

The field name itself is generated by the deletedNodeId inflector in <ref_snippet file="/home/ubuntu/repos/constructive/graphile/graphile-simple-inflector/src/index.ts" lines="211-215" />:
typescript
deletedNodeId(this: PgInflection, table: PgClass) {
return this.camelCase(
deleted-${this.singularize(table.name)}-${nodeIdFieldName}
);
}

What is NodeId?

NodeId is PostGraphile's implementation of Relay's Global Object Identification spec - a globally unique, opaque ID that encodes the table name and primary key. It's used for:

  1. The node(nodeId: ID!) query to fetch any object by its global ID
  2. Cache invalidation in Relay clients (the deletedNodeId field)

Skipping NodePlugin removes:

  • The nodeId field on types
  • The node query

But it does NOT remove:

  • The deletedNodeId field on delete mutation payloads (added by mutation plugins)

If you want to remove deletedDatabaseNodeId, you'd need a custom plugin to omit that field from mutation payloads, or use smart tags to omit it.

@yyyyaaa
Copy link
Contributor Author

yyyyaaa commented Jan 20, 2026

removed the deleted<entity>Id returning types altogether, kept clientMutationId by default, which everything has

@yyyyaaa
Copy link
Contributor Author

yyyyaaa commented Jan 20, 2026

1 test failing, fixing

@yyyyaaa yyyyaaa force-pushed the fix/codegen-deletedId-not-working branch from 8dc37f9 to c595778 Compare January 20, 2026 04:39
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
@yyyyaaa yyyyaaa force-pushed the fix/codegen-deletedId-not-working branch from c595778 to 63929a2 Compare January 20, 2026 04:47
@pyramation pyramation merged commit c545b26 into main Jan 20, 2026
37 checks passed
@pyramation pyramation deleted the fix/codegen-deletedId-not-working branch January 20, 2026 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants