Question on paging - if i have a record set i need...
# prisma-whats-new
j
Question on paging - if i have a record set i need that is <2,500 records but >1,000 - is that right way to handle that to use graph.cool pagination or can i leverage apollo fetchMore somehow? Wondering what the graph.cool/apollo way to do: while (!outOfRecords) { fetchNextSet} while keeping all the magic of the store/subscriptions/etc. working and would appreciate any input, thanks!
My plan now is just to hit that query three times with a $skip: Int! variable, but wanted to make sure i wasn't missing a better way.
n
Hey @jeffo, that would have been my first approach as well! You can also use the meta query to count the amount of nodes: https://www.graph.cool/docs/reference/simple-api/traverse-the-graph-aihaeph5ip/#meta-data-for-edges
j
Thanks @nilan, what a great platform you have created! I ended up solving it this way: i have a query returning allProducts named 'products' connected to the page, if i add this, i see second page 🙂 just copying in case it helps anyone else searching: this.props.products.fetchMore({ variables: { skip: 1000}, updateQuery: (previousResult, { fetchMoreResult }) => { const newProducts = fetchMoreResult.allProducts; return { allProducts: [...previousResult.allProducts, ...newProducts], }; }, });
and bam my page gets live updated 🙂
n
awesome! thanks for sharing