Skip to content

[TypeGen]: support select in generated TanStack Query hooks - #24

Merged
MistyKuu merged 1 commit into
MistyKuu:masterfrom
RejectKid:tanstack-query-select
Nov 20, 2026
Merged

MistyKuu merged 1 commit into
MistyKuu:masterfrom
RejectKid:tanstack-query-select

Conversation

@RejectKid

Copy link
Copy Markdown
Contributor

Summary

Generated GET hooks now accept an optional TanStack Query select callback so components can work with the part of a response they need directly from the generated hook.

const { data: users } = useGetUsers({ page: 1 }, {
  select: response => response.items,
});

TypeScript infers the selector input from the endpoint response and the hook's data from the selector's return value. The query cache stores the full response, and existing calls that omit select still receive that response. The feature uses the existing TypeGen configuration.

Affected package(s)

ZibStack.NET.TypeGen and its documentation.

Type of change

  • New feature
  • Generator / generated-code behavior change

How was this verified?

All 290 TypeGen Release tests passed. A new compile test uses TanStack Query v5's actual types and verifies inferred results for required, optional, and absent endpoint inputs, with query options factories enabled and disabled. It also checks that an incompatible selector and a requested selected type without a selector are rejected.

dotnet test packages/ZibStack.NET.TypeGen/tests/ZibStack.NET.TypeGen.Tests/ZibStack.NET.TypeGen.Tests.csproj -c Release

Checklist

  • Branched from master, focused on a single change
  • Tests added or updated
  • Emitter documentation and package README updated
  • No new build warnings
  • Commit subject uses the [Package]: … prefix

@MistyKuu
MistyKuu merged commit 30983ea into MistyKuu:master Nov 20, 2026
1 check passed
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.

2 participants