lukemorales / query-key-factory

A library for creating typesafe standardized query keys, useful for cache management in @tanstack/query
https://www.npmjs.com/package/@lukemorales/query-key-factory
MIT License
1.16k stars 32 forks source link

Support for TanStack Query v5 #73

Open lithdew opened 1 year ago

lithdew commented 1 year ago

Hi,

I wanted to put up a feature request for support for TanStack Query v5 which makes defaultPageParam mandatory in useInfiniteQuery and exposes pageParam and direction in QueryFnContext.

If there might be interest in supporting it, I would be happy to offer some help too.

Daniel3711997 commented 9 months ago

any news here?

gbyesiltas commented 9 months ago

I have the same issue.

Additionally, I am having some issues with useQueries on v5. Queries that I define through query-key-factory that work fine with useQuery seem to have typing issues with useQueries. See screenshots:

Screenshot 2023-11-28 at 12 13 57 Screenshot 2023-11-28 at 12 14 08
lukemorales commented 9 months ago

Hey everyone, thank you for the suggestion in adding support for v5 new APIs, unfortunately I've been very busy lately without being able to put too much work into new features (the type system is extremely complex by now, so it takes some effort to add new things and not break things). I'll put this on my radar, but can't guarantee something in the near future.

Also, since there are some changes in APIs for V5, it would probably make sense to have a new major version with support only for v5 instead of adding here and being incompatible with a lot of folks that are still using V4.

@gbyesiltas from what I can see in your TS errors, the queries for useQueries expect some kind of MaybeRef that is making it incompatible with the normal function declaration. I'll need to understand the different signature it is expecting and see how we can make the type declaration compatible with its signature

gbyesiltas commented 9 months ago

Update from my side about useQueries, looks like this PR from tanstack-query did fix the typing issue :) 🥳

MartinHarkins commented 3 months ago

Hey hey, we're interested in this ;)