# How to implement cursor based pagination when elements can be deleted, which can invalidate the stored cursor?

**URL:** https://community.apollographql.com/t/how-to-implement-cursor-based-pagination-when-elements-can-be-deleted-which-can-invalidate-the-stored-cursor/7983
**Category:** Client SDKs
**Tags:** client
**Created:** [December 8, 2024, 3:16pm UTC](https://community.apollographql.com/t/how-to-implement-cursor-based-pagination-when-elements-can-be-deleted-which-can-invalidate-the-stored-cursor/7983 "2024-12-08T15:16:50Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![TheTrio](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/thetrio/32/5399_2.png) [@TheTrio](https://community.apollographql.com/u/TheTrio)
#### Post date: [December 8, 2024, 3:16pm UTC](https://community.apollographql.com/t/how-to-implement-cursor-based-pagination-when-elements-can-be-deleted-which-can-invalidate-the-stored-cursor/7983/1 "2024-12-08T15:16:50Z")

</div>

I have a query which looks a bit like this

```auto
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!
