Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

222
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!