When reactHooks is enabled, the generator currently creates React Query hooks using useQuery. With TanStack Query v5, useSuspenseQuery is increasingly used for Suspense-based data fetching.
It would be useful to support generating useSuspenseQuery hooks.
Proposed config option
Add a configuration option in swagger.config.json, for example:
{
"reactHooks": true,
"useSuspenseQuery": ["getUsers", "getProfile"]
}
or alternatively:
{
"reactHooks": true,
"suspense": true
}
Example generated hook
export const useGetUsers = (params: GetUsersParams) =>
useSuspenseQuery({
queryKey: ["getUsers", params],
queryFn: () => getUsers(params),
});
Why
Aligns with TanStack Query v5 patterns
Enables React Suspense usage without manual hook rewriting
Keeps configuration consistent with existing options like useQuery and useInfiniteQuery
Happy to open a PR if this approach is acceptable.
When reactHooks is enabled, the generator currently creates React Query hooks using useQuery. With TanStack Query v5, useSuspenseQuery is increasingly used for Suspense-based data fetching.
It would be useful to support generating useSuspenseQuery hooks.
Proposed config option
Add a configuration option in swagger.config.json, for example:
{
"reactHooks": true,
"useSuspenseQuery": ["getUsers", "getProfile"]
}
or alternatively:
{
"reactHooks": true,
"suspense": true
}
Example generated hook
export const useGetUsers = (params: GetUsersParams) =>
useSuspenseQuery({
queryKey: ["getUsers", params],
queryFn: () => getUsers(params),
});
Why
Aligns with TanStack Query v5 patterns
Enables React Suspense usage without manual hook rewriting
Keeps configuration consistent with existing options like useQuery and useInfiniteQuery
Happy to open a PR if this approach is acceptable.