Skip to content

feat(codegen): scaffold feature mutations with the correct apiClient pattern#305

Merged
agjs merged 1 commit into
mainfrom
feat/scaffold-feature-mutations
Jul 15, 2026
Merged

feat(codegen): scaffold feature mutations with the correct apiClient pattern#305
agjs merged 1 commit into
mainfrom
feat/scaffold-feature-mutations

Conversation

@agjs

@agjs agjs commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Why

new:feature scaffolds Feature.queries.ts (with the correct const { data } = await apiClient.GET(...) pattern in a doc comment) but no mutations file. So a resource's create/update/delete code gets written from scratch, and the recurring mistake is guarding response.error — which this stack forbids: errors throw via the client middleware, so response.error is typed undefined and every guard is a dead @typescript-eslint/no-unnecessary-condition error (observed 4–6 per feature in an autonomous build, ~15 min of thrash).

What

  • Scaffold Feature.mutations.ts: a compiling useCreate<Feature> stub + the correct pattern documented inline (destructure { data }, never touch response.error), mirroring the queries stub.
  • Add the same "errors throw — don't check response.error" note to the queries stub comment (queries.ts hit the same lint error).

The model now fills domain fields on right-shaped code instead of inventing client plumbing.

Verified

new:feature Widget → generated Widget.mutations.ts + Widget.queries.ts are lint-clean and typecheck-clean.

…pattern

new:feature generated queries (with the correct 'const { data } = await apiClient.GET'
pattern in a doc comment) but NO mutations file — so a resource's create/update code
was written from scratch, and the common mistake was guarding response.error, which
this stack forbids (errors throw via the client middleware, so response.error is typed
undefined → dead no-unnecessary-condition lint errors, 4-6 per feature).

Scaffold Feature.mutations.ts with a compiling useCreate stub plus the correct pattern
documented inline (destructure { data }, never touch response.error), mirroring the
queries stub. Also add the same 'errors throw — don't check response.error' note to the
queries stub comment. The model now fills domain fields on right-shaped code instead of
inventing client plumbing.

Verified: new:feature Widget → generated mutations + queries lint-clean and typecheck-clean.
@agjs agjs merged commit a47da39 into main Jul 15, 2026
29 checks passed
@agjs agjs deleted the feat/scaffold-feature-mutations branch July 15, 2026 21:15
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