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

111
Views
Apollo fetchMore updates data globally

I have two TaskList components that use the same query GET_TASKS.

Both use a different filter query variable which is passed down to them in props as queryVars.

I defined a standard merge function in type policies to merge the incoming and existing data together.

The TaskList component uses

const { data, fetchMore } = useQuery<Response, Variables>(GET_TASKS, { variables: queryVars })

to retrieve the data.

A Fetch more button has () => fetchMore({ variables: queryVars }) in the onClick attribute.

When I click on the Fetch more button on the left, the tasks on the right get updated as well, however, without its filter applied, so the data that come with Assigned to me filter are also put to the Assigned by me task list and vice versa.

The merge function basically rewrites every data object that uses the given query.

How do I tell Apollo to only update the data that is bound to the component where fetchMore is defined?

task lists

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You should be able to add filter to the keyArgs property. This should create different cache results based on the filter.

const cache = new InMemoryCache({
  typePolicies: {
    Query: {
      fields: {
        tasks: {
          keyArgs: ["filter"],
          merge(existing, incoming, { args: { offset = 0 }}) {
            //Custom merge
          },
        },
      },
    },
  },
});
about 4 years ago · Santiago Trujillo Report
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!