0

I'm making a clone of social app. I'm using graphQL as my backend. My problem is that every time I query a list of data it is returning the same result. When I will release that app, the user base will be very small so the amount or data is less in number. So I'm facing the issue described below:

1. My data in data base is like:

I'd=1 title=hello1

I'd=2 title=hello2

I'd=3 title=hello3

2. When I'm querying data through pagination with limit=3, I'm getting list of items is like:

Query 1

I'd=1 title=hello1

I'd=2 title=hello2

I'd=3 title=hello3

3. When I'm adding new items to data base, it is invoked in between the items like below:

I'd=1 title=hello1

I'd=4 title=hello4

I'd=2 title=hello2

I'd=3 title=hello3

I'd=5 title=hello5

4. So next fresh query result(limit=3) Will be like:

Query 2

I'd=1 title=hello1

I'd=4 title=hello4

I'd=2 title=hello2

Look at the data set previously our query result was: I'd=1,2 & 3 now I'd=1,4 & 2 so the user will get same result as id=1,2 is in new list.

If I will save pagination nextToken/cursor(I'd=3) of first query(query 1) then after new data added to data base the new query will start from I'd=5, because it is present after I'd=3. Look at the new dataset it will miss I'd=4 because nextToken is saved for I'd=3 for the query will start from I'd=5. Hope you can understand.

If your suggestion is add a sort key of created at, I want say that if I will add some filter, the data set will become so much selective that might become the reason of limited number of data in feed and we know a feed should query unlimited data.

the coder
  • 31
  • 3
  • I removed the conflicting DBMS tags. Please add only **one** tag for the database product you are really using. –  Sep 10 '22 at 06:00

0 Answers0