首页 > 解决方案 > 不能在阿波罗突变的更新方法中使用等待

问题描述

我正在尝试更新缓存以触发 UI 的重新渲染,但update如果您使用 apollo 突变的方法似乎无法正常工作async/await

mutation({
  variables: {
    ...
  },
  update: async (cache, responseFromMutation) => {
    ...
    const someFunctionResult = await someFunction()
    proxy.writeQuery({...}) // this writes to cache but doesn't trigger rerendering of UI. If we take out the `await` it works.
  }
})

有任何想法吗?

标签: reactjsapollo-clientreact-apollo

解决方案


推荐阅读