usePaginationQuery hook #2120
-
Hi, I'm somewhat new to URQL and still exploring its features, best-practices and eco system. Something that I'm still struggling with is Pagination, especially when trying to query the data as well in a paginated inifinite scrolling manner as well as as in a selective way (eg. first 3 for a preview or so).
I was wondering if there are further possibilities such as encapsulating the paging logic into a hook, such as I was thinking about a shape more or less like that, given a relay compliant Connection is used: // same return type & first parameter as useQuery
// second parameter for paging details, could provide good defaults
const [result] = usePaginationQuery({query: QUERY, variables: {}}, {pathToPageInfo: "node.friends.pageInfo", pageSize: 10}) The hook would encapsulate the logic of storing the "after" cursor and related responses, could flush them once variables or Query changes, etc… Does somebody have experience in that area? Are there other approaches that you could recommend? Thanks a lot in advance 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Personally a big fan of this where you actually hold caches of pages as this is both efficient in your data-cache and your rendering process thanks to keys. |
Beta Was this translation helpful? Give feedback.
Personally a big fan of this where you actually hold caches of pages as this is both efficient in your data-cache and your rendering process thanks to keys.