【问题标题】:How can I have apollo-module automatically refetch queries on query param updates如何让 apollo-module 自动重新获取有关查询参数更新的查询
【发布时间】:2023-03-10 14:08:01
【问题描述】:

我最近从手动调用 Hasura 客户端转为使用 Apollo-module

我在@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
    }
  }

但是,它仅在页面加载时获取数据,然后当查询更改时,数据会丢失,我必须手动重新获取它们造成延迟,加载选项也会丢失,因此我也无法使用该选项。任何线索都会有所帮助,谢谢

【问题讨论】:

标签: javascript graphql nuxt.js apollo hasura


【解决方案1】:

对于遇到类似问题的任何人,我已通过使用网络获取策略为我解决了这个问题。我加了

fetchPolicy: 'network-only'

【讨论】:

  • 这将永远不会使用 Apollo 缓存。
猜你喜欢
  • 2021-11-23
  • 2019-12-13
  • 2021-01-27
  • 2021-01-16
  • 2019-11-30
  • 2021-11-26
  • 1970-01-01
  • 2018-10-08
  • 2021-04-29
相关资源
最近更新 更多