Skip to content

Add TanStack Query v5 client generation to TypeGen #18

@RejectKid

Description

@RejectKid

Title

Add TanStack Query v5 generation to TypeGen

Summary

Add first-class TanStack Query v5 client generation to ZibStack.NET.TypeGen.

This would introduce TypeTarget.TanStackQuery and fluent TanStackQuerySettings, allowing TypeGen to emit typed TanStack Query client code from the discovered endpoint model.

Generated output should include fetch functions, query keys, queryOptions, mutationOptions, React hooks, prefetch helpers, and invalidation helpers.

TypeGen should also read Minimal API .WithName(...) and .WithTags(...) metadata so operation names and query-key groups can be controlled through normal Minimal API conventions.

Motivation

Some team members have asked whether Zib can support generated TanStack Query clients.

This would reduce repeated frontend boilerplate in React apps by generating the query keys, fetch wrappers, hooks, and cache helpers directly from the .NET API shape while preserving type safety.

Example

app.MapGet("/users/{id}", GetUserById)
   .WithName("GetUserById")
   .WithTags("Users");

Could generate:

export const usersKeys = {
  detail: (id: string) => ['Users', 'GetUserById', id] as const,
};

export function useGetUserByIdQuery(id: string) {
  return useQuery({
    queryKey: usersKeys.detail(id),
    queryFn: () => getUserById(id),
  });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions