-
-
Couldn't load subscription status.
- Fork 591
Description
When using openapi-ts together with openapi-react-query, it seems that getQueryData does not correctly infer the type for the data associated with a query created via client.queryOptions.
Example:
const customersQueryOptions = client.queryOptions(‘get’, ‘/customers’, queryArguments);
const oldData = queryClient.getQueryData(customersQueryOptions.queryKey);
// ^ not inferred! oldData is `unknown`Expected:
oldData should have the same type as the data returned by the /customers endpoint.
Actual:
oldData is not correctly typed — TypeScript does not infer the correct shape from the query options.
Proposal
It looks like the type information from queryOptions is not being propagated to the getQueryData (but also for setQueryData) method.
Would it be possible to make queryKey carry the full type context (like ReturnType or generics) so that getQueryData gets proper inference?
Extra
- I’m willing to open a PR (see CONTRIBUTING.md)