I have a query which looks a bit like this
query Person($cursor: ID, $limit: Int) {
items:{
...
}
name
...
cursor
}
I fetch the initial — let’s say 100 — items and store the cursor. When I need to fetch more items, I pass in the cursor I got from the first query’s result to the current query and bob’s your uncle.
However, the user can also mutate these items. Let’s say the user deletes an item. I can use either writeFragment or cache.modify directly to delete it from the array. But the trouble occurs when I need to fetch more data.
From what I’ve noticed by playing around with the API, the cursor maps to the items. For example, say I delete the 2nd last item. The cursor to fetch more still remains the same. However, if I delete the last item, the current cursor is now invalid.
I’m not even sure if I can rely on this observation but I’m wondering how people implement cursor styled pagination where in the cursor might get invalidated due to mutations. Is there a pattern in apollo which can help this?
Thanks!