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

222
Vistas
How to refetch apollo query after i redirect to page with Vue Router?

I delete some resource in a page via apollo mutation:

async delete () {
  await this.$apollo.mutate({
    mutation: orderDelete,
    variables: {
      id: this.order.id
    }
  })

  this.$emit('success')
}

This is the method triggered by success emitter:

onOrderDeleted () {
  this.closeModal('modalOrderDelete')

  this.$nextTick(() => {
    this.redirectToClient()
  })
},
redirectToClient () {
  this.$router.push({
    name: 'clients.show',
    params: { clientKey: this.clientKey }
  })
}

Here is what happen: when the page is redirected to clients.show the order is still being show even if i deleted it, it only updates if i refresh the whole page.

So i would like to know how i trigger a query refresh when i redirect to this page? Apollo is probably keeping data in cache and not updating it, i don't know how to update the cache only of this specific query, but all programatically because the user will be redirect via Vue Router.

Note: clients.show shows a list of orders, so it should update the orders removing that one i just deleted, but it just doesn't change.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

this.$apollo.mutate() has more features than you used:

The object looks like this:

this.$apollo.mutate({
  mutation: someGql,
  variables: {
    label: param1,
  },
  update: function(store, response) => {
    // how to update the store
  },
  optimisticResponse: theResponseYouExpect,
})

So, you sent the gql, but did not handle the response from that query (neither the real response from the server or the optimistic response (that you expect on success))

More on Vue Apollo mutation here.

about 4 years ago · Juan Pablo Isaza 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