question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pollInterval not working with offset-based fetchMore pagination

See original GitHub issue

I’m using fetchMore to implement offset-based pagination as suggested in the docs, and that works. But when I add pollInterval to refresh the data, it wipes out all the newly loaded data every time the interval triggers.

What am I doing wrong?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:34 (14 by maintainers)

github_iconTop GitHub Comments

8reactions
smeijercommented, Mar 8, 2018

Wouldn’t this issue actually be solvable when a poll used an updateQuery similar to fetchMore? If updateQuery had a parameter that told us if it was triggered by a poll, or a fetchMore request, we could update the prevResult with fetchMoreResult / pollResult accordingly.

7reactions
kadikramancommented, Dec 7, 2018

I have an infinite list that uses fetchMore, but needs to be polled for items (think twitter). So basically same problem as y’all. This is how I solved it:

My API is already implementing the cursor approach where I send the id of the latest item and it’ll give me the next 10.

  1. added a param firstItemId to my api where instead of sending the next 10, it returns all newer items
  2. added a query, nested inside the original paginated query that just polls the list with firstItemId every 2 seconds
  3. use onCompleted to manually add the new items to the cache

So far it works. I can’t quite decide if it’s a clever solution or just a giant hack. Maybe it’s both 😄

@smeijer 's suggestion would 💯 fix this problem. Hope it gets implemented some time!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Core pagination API - Apollo GraphQL Docs
Our fetchMore function is ready, but we're not finished! ... section use offset-based pagination, but this article applies to all pagination strategies.
Read more >
Poll interval option on Apollo client useQuery hook not working
I have a simple forum-like app using apollo server and client(react) and I am trying to periodically update the posts on the main...
Read more >
Pagination – Angular - GraphQL Code Generator
Pagination is the most common solution to this problem, ... Offset based pagination - also called numbered pages - is a very common...
Read more >
GraphQL Pagination Primer: Offset vs. Cursor vs. Relay-Style ...
Historically, offset-based pagination has been a popular choice for ... A cursor-based approach has the downside of not providing any way to ...
Read more >
How to implement infinite scroll with GraphQL and React
How can you create infinite scroll offset-based pagination in your React ... fetchMore() that you can use to implement offset pagination with infinite ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found