Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
How to keep just the last cached query in Apollo client?

I have a paginated graphQL-Query in my react app, which can paginate thousands of rows. The pagination is processed at server. Now I want to use fetchPolicy cache-first, to be able to load a paginationQuery from cache, if i.e. user returns from back to a visited route which uses the paginated data.

This works, but to not overload the memory, I don't want to keep every ROOT_QUERY in cache (over time, the more often the user displays his data differently (different page, different sorting, different filter, etc. ...), the cache would grow immensely). How can I achieve to keep just the last cached query.

i.e.

  const { loading, error, data } = useQuery(GQL_QUERY, {
    variables,
    fetchPolicy: 'cache-first',
    onCompleted: () => {
      //clear old cached versions of my GQL_QUERY no matter what parameters
    }
  });

Thanks

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!