Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

113
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda