美文网首页
apollo cache

apollo cache

作者: younglaker | 来源:发表于2019-08-19 19:19 被阅读0次

问题:
使用query获取了数据,更新后想要再次query获取新的数据,由于Apollo会优先使用cache

解决方案:

  • update方法更新cache

  • refetch

  • subscription

  • 清空存储query的数据,手动新增、删除数据到state的存数据的变量里

  • 不使用cache

const defaultOptions = {
  watchQuery: {
    fetchPolicy: 'no-cache',
    errorPolicy: 'ignore'
  },
  query: {
    fetchPolicy: 'no-cache',
    errorPolicy: 'all'
  }
};

export default function WoodyApolloClient() {
  return new ApolloClient({
    link: createHttpLink({
      uri: woodyUrl,
      headers: {
      },
      options: {
        reconnect: true
      }
    }),
    cache: new InMemoryCache(),
    defaultOptions: defaultOptions
  });
}

相关文章

网友评论

      本文标题:apollo cache

      本文链接:https://www.haomeiwen.com/subject/ljwesctx.html