Search code examples
javascriptgraphqlnuxt.jsapollohasura

How can I have apollo-module automatically refetch queries on query param updates


I've recently moved from manually calling my Hasura client to using Apollo-module.

I added this under @Component

apollo: {
    features: {
      query: gql`query { features { id, name } }`
    },
    tenants: {
      query: gql`query { tenants { id, name } }`
    },
    listings: {
      query () {
        return gql`${(this as any).buildListingsQuery()}`
      },
      prefetch: true
    }
  }

However it only fetches the data on page load, then when the query changes the data is lost and I have to manually refetch them creating a lag, also the loading option is lost so I can't use that one either. Any leads would help, thank you


Solution

  • For anyone that goes through a similar issue, it was fixed for me by using the network for the fetch policy. I added

    fetchPolicy: 'network-only'