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

224
Visualizações
Cache Nuxt Apollo Search Results

I have a search using nuxt-apollo. If I search a product and then navigate to it's corresponding page from search and decide to go back to search, search results reset to what was initially returned before search. I assume this is a cache-related thing, and would like to figure out how to keep new search results cached. Is the solution to use Vuex to store the results? Or is there some simple cache update function I can use within Apollo?

search.vue

// apollo search
apollo: {
    products: {
      query: filteredProducts,
      loadingKey: 'loading',
      variables() {
        return {
          query: this.query.queryString,
          first: this.resultsCount,
          sortKey: this.query.sorting,
          reverse: this.query.reverse,
          afterItemCursor: null,
        }
      },
      result(data) {
        return data.products
      }
    }
  },
// update search method
  updateSearch() {
    // update search parameters triggering an auto refetch from nuxt-apollo
    this.filterDialogOpen = false
    this.query.queryString = this.formatQuery
    this.query.sorting = this.selectedSortingOption.value
    this.query.reverse = this.selectedSortingOption.reverse

    // push formatted query to router query
    this.$router.push({
      query: {
        search: this.formatQuery
      }
    })
  }

Before you mark this as duplicate... It's worth noting that nuxt-apollo is built on vue-apollo but with some additional quirks here and there. I have no problem accomplishing this in my other projects by updating the router query, and the results cache... but nuxt-apollo seems to function differently in that regard. Any help is appreciated, thanks!

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