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.

In case of pagination, how can I refresh all pages?

See original GitHub issue

I am using the latest version of react-apollo with meteor

Intended outcome: I have a paginated list. I would like to add a reload button to this list. On reloadig, the current data should be erased, and new data should be fetched from the server on all pages of that list.

Actual outcome: I have tried to trigger .refetch() with this button. But it refetches only the current page. If other pages were visited before the reloading button is triggered, the data of those pages is stored in the store and is not refetched.

Triggering .resetStore() resets the whole store and all queries on the page. Which is obviously an overkill…

My question is:

Am I using .refetch() wrong? What would be the right approach?

Or am I using .resetStore() wrong? Is it possible to reset the store of one specific query?

Thank you!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
dallonfcommented, May 26, 2017

Is fetchMore intended to be used for page-based pagination in the UI? It seems more designed for things like infinite scrolling… looking at the examples, it’s not clear how one might implement a more traditional paginated view. I’m talking about this sort of thing:

image

Note that it’s not guaranteed that a user will click “Next” - they might go from Page 1 to Page 5 and then to Page 3.

3reactions
allanesquinacommented, Aug 6, 2020

Hi @furkanDogu,

The workaround I found for that problem was to use an internal cache to control which type of query I want to refetch. E.g.

// Create a cache param in your gql schema
const { loading, error, data, refetch } = useQuery(GET_USERS, {
    variables: {
      number: page, 
      size: numPerPage,
      cache: internalCache('userListPagination').toString(), // Get the cache value each time
    },
    notifyOnNetworkStatusChange: true,
  })


// So when you change something, just renew the cache for that type of query.
// as soon as your query has a new value, the Apollo Client will automatically refetch
internalCache('userListPagination', Date.now())

It’s been working well here so far, if anyone has something better, I want to know too!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pagination design, reload entire page or reload just the ...
Approach 2: Once the user clicks on page2, I do an AJAX call, get the next 10 results in JSON/XML format and reload...
Read more >
How to reload page the page with pagination in Angular 2?
The refresh doesn't work and only brings the user back to the first page. It can depend on how your routing is set...
Read more >
Why does pagination refresh page every time? - General
Every time you click next / previous, the page is refreshed on the the live site. But in preview mode, it works as...
Read more >
How to refresh webpage when click next page in pagination?
I have just set up data tables on my website. I want to be able to reload the webpage when i click the...
Read more >
RE: Page Refresh Issue in Pagination - Forums - Liferay
Hi delang, In this case, you have to submit only division of your page. you have to use AjaxUtil method to submit the...
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