reactjs - 变异后 Apollo 客户端使用 cache.modify 差异更新缓存
问题描述
嗨,我只是想问一下下面这两个代码有什么区别我正在尝试在突变后更新评论缓存我尝试了下面的这两个代码片段,它都可以正常工作。我只需要知道区别。谢谢
update(cache, { data }) {
cache.modify({
id: cache.identify(myPost),
fields: {
comments(existingCommentRefs, { readField }) {
return existingCommentRefs.filter(
commentRef => idToRemove !== readField('id', commentRef)
);
},
},
})
}
update(cache, { data }) {
cache.modify({
fields: {
comments() {}
}
})
}
解决方案
推荐阅读
- jenkins - 如何在 Jenkins 中恢复旧用户、作业和配置?
- php - 如何防止 laravel 中的 html 编码(特殊字符)?
- excel - Excel VBA动态公式
- jenkins - 为什么我在设置 ssh-slave docker 映像时收到错误“服务器拒绝了 1 个私钥”错误
- python - 如何在 PyQt5 中横向打印?
- c - GCC 未定义的参考。找不到图书馆
- java - 使用请求和响应的字符串调用 SOAP Web 服务的最简单方法是什么?
- python-2.7 - 如何修复 urlopen 错误 [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:590)> 错误
- python - 在字符串 python 中搜索列表的特定项目
- python - 创建一个新列,它是所有前面的列的串联