Skip to content

fix(codegen): include partition keys in hooks update/delete mutation variables#1296

Merged
pyramation merged 1 commit into
mainfrom
feat/codegen-hooks-extra-keys
Jun 14, 2026
Merged

fix(codegen): include partition keys in hooks update/delete mutation variables#1296
pyramation merged 1 commit into
mainfrom
feat/codegen-hooks-extra-keys

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

Extends the partition key fix from PR #1295 (ORM model generator) to also cover React Query mutation hooks.

Previously, generateUpdateMutationHook and generateDeleteMutationHook only included the primary key field in the mutation variable type. For partitioned tables (e.g. those with databaseId), the generated hooks would produce type errors because the ORM's where type now requires the extra keys.

Changes:

  1. Extracted getExtraInputKeys to shared utils.ts — was previously a private function in model-generator.ts. Both ORM and hooks generators now import from the same source.

  2. mutations.tsgenerateUpdateMutationHook: discovers extra required fields via typeRegistry, adds them to updateVarType, the destructured arrow param, and the ORM .where object.

  3. mutations.tsgenerateDeleteMutationHook: same treatment — extra keys appear in deleteVarType, destructured param, and .where.

  4. MutationGeneratorOptions gains typeRegistry?: TypeRegistry, threaded from index.ts via customOperations.typeRegistry.

// Before (generated hook):
mutate({ id: 'abc' })
// → Error: databaseId is required

// After:
mutate({ id: 'abc', databaseId: 'xyz' })
// → works

Link to Devin session: https://app.devin.ai/sessions/b2291a8e333e445aa125a2efd1996206
Requested by: @pyramation

…variables

Extracts getExtraInputKeys to shared utils, applies to both ORM model-generator
and React Query mutation hooks. Update/delete hooks now include extra required
fields (e.g. databaseId for partitioned tables) in the variable type, destructured
params, and ORM where clause.
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@pyramation pyramation merged commit ee34c91 into main Jun 14, 2026
37 checks passed
@pyramation pyramation deleted the feat/codegen-hooks-extra-keys branch June 14, 2026 18:54
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.

1 participant