Inconsistent cache key - queryOptions
requires third parameter and not for useQuery
/useSuspenceQuery
#1972
Closed
2 tasks done
Labels
Description
I'm using this library in conjunction with
@tanstack/router
and I'm using their loaders to load data at the route level. This works, but the API is different based on if I useuseQuery
/useSuspenceQuery
vsqueryOptions
.Ultimately, I need both to have the same third parameter for the query cache key to be the same, because if I add a third parameter in the
queryOptions
such as{}
and only have two parameters for myuseQuery
/useSuspenceQuery
, I will have two different query cache keys, e.g.:And if I don't add a third parameter to
queryOptions
:openapi-fetch
0.13.0
openapi-react-query
0.2.3
@tanstack/react-query
5.59.16
20.11.0
macOS 15.0.1
Reproduction
For example, I have the following code snippet:
Which gives the error above, adding a third parameter to
queryOptions
satisfies TypeScript, but creates duplicate cache keys.Expected result
To not need to provide a third parameter to
queryOptions
to be consistent to withuseQuery
/useSuspenceQuery
Checklist
npx @redocly/cli@latest lint
)Upon looking further, I see that
queryOptions
is being used foruseQuery
/useSuspenceQuery
, which makes sense, and are dismissing the TS error by casting the type of the third parameter viaas InitWithUnknowns<typeof init>
- https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-react-query/src/index.ts#L135The text was updated successfully, but these errors were encountered: