Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

112
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda