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

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

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 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