-
I want to use infinite paging but it doesn't seem to be built for search before/after paging (very stable paging) where page numbers are not used (think bidirectional cursor). I have search endpoints that works like stripes paging where you specify either (but not both) the searchBefore or searchAfter value. return useInfiniteQuery<IResponseWrapper<SomeModel[]>, ProblemDetails>(
[queryKey],
({ pageParam = 0 }) => {
return axios.get......("some-resource"); // returns { status, headers, data: SomeModel[] }
},
{
getPreviousPageParam: (firstPage, pages) => firstPage.headers["searchbeforetoken"],
getNextPageParam: (lastPage, pages) => lastPage.headers["searchaftertoken"] My main question is how can I be very specific about the which direction is being requested (previous or next) as I need to know if it's for searchAfter or searchBefore. I was thinking I could look at the My second question, is there any way I can mutate the results for onSuccess and onError so I can return just the data payload and hide the internal state (headers / status). I need to expose the headers for paging needs but I don't want it polluting the rest of the app. Would be nice to maybe also cache this data and possibly get it from query cache? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
@tannerlinsley any advice on how to achieve this? |
Beta Was this translation helpful? Give feedback.
-
you can return whatever you want from
|
Beta Was this translation helpful? Give feedback.
you can return whatever you want from
getNextPageParam
orgetPreviousPageParam
- it doesn't have to be a number. So you can include the paging direction, something like: