I have a "classic" cursor based pagination of items.
I have to do two things with this items:
fetch all items of this list when components did mount
refetch all the list when a button is pressed
Using react-apollo for the first point my solution is:
use a
Querycomponent to load the first data setwhen the last fetched data set is loaded I get the
endCursorfrom ituse the
endCursorand thefetchMore(from theQueryrender props) to load the next data set (passingvariablesandupdateQueryto thefetchMorefunction)if there are more results loop to #2
For the second solution:
I'm using
refetch(from theQueryrender props) to reload the piece of the store with new dataUse the same loop of the first solution (with the
loadMorefunction) to fetch other results
All of these implementations are not so easy to write / maintain / reuse, so my question are:
am I missing something? there is a better solution to this scenario?