T
TanStack17mo ago
wise-white

Should I include count/skip parameters in the query key for infinite queries?

Suppose I have a paginated API which accepts the parameters count (page size) and skip . Should either of these parameters be included in the query key for an infinite query? I've noticed in the docs, the cursor parameter (analogous to skip) is never included in the query key. * Not including cursor makes sense to me, as all the state regarding the current and initial page is encoded in RQ (page param). Combined with pageParam, we have everything we need to fetch next/previous page without encoding it in the query key * however, I'm not sure about if I should include count in the query key. For example, suppose we have one part of the app that only fetches 50 items with infinite scroll, vs another part that fetches 100 items without infinite scroll. It seems in this case we should encode the count into the query key Thanks for the help!
1 Reply
variable-lime
variable-lime17mo ago
if you hard-code count, you don't need to include it. if it's a variable that can change over time, you should. our linter warns you in that regard

Did you find this page helpful?