openapi-react-query-codegen
openapi-react-query-codegen copied to clipboard
Prefetch hook keys aren't properly set
Describe the bug I started using the prefetch hooks introduced a few days ago, but the dynamic key is hardcoded, making it challenging to use the prefetched data because the keys do not match.
To Reproduce Just generate the hooks and check the prefetch code.
Here is an example of the code generated:
export const prefetchUseFooServiceGetBar = (queryClient: QueryClient) =>
queryClient.prefetchQuery({
queryKey: [Common.useUseFooServiceGetBarKey, []],
queryFn: () => FooService.getBar(),
});
OpenAPI spec file N/A
Expected behavior Similar to a query hook, the keys must be dynamic so we can tell React Query what key should be used for caching:
export const prefetchUseFooServiceGetBar = (queryClient: QueryClient, queryKey?: TQueryKey) =>
queryClient.prefetchQuery({
queryKey: Common.useUseFooServiceGetBarKeyFn(queryKey),
queryFn: () => FooService.getBar(),
});
Screenshots
- OS: MacOS
- Version: 14.4.1
Additional context N/A