cache.writequery只是,不添加到缓存
我正在使用cache.writequery
在突变后更新我的缓存,而它只是没有更新缓存。更新不在那里。
这是在我的update()
usemuont 的回调中:
const userData = copy(cache.readQuery({
query: GET_USER
}))
userData.me.categories.push(newCategory)
cache.writeQuery({
query: GET_USER,
data: userData
})
console.log('New category shows up here:')
console.log(userData.me.categories.map(category => category.id))
const _userData = copy(cache.readQuery({
query: GET_USER,
}))
console.log('New category is not in here:')
console.log(_userData.me.categories.map(category => category.id))
我正在深入关注我的用户数据,并只是将其推向其类别。它只是不想存储更新的数据。显然,在我可以突变我所有现有类别并更改其名称等的情况下,它在做 ,它不会添加新的类别。
接下来我可以尝试什么?
I'm using cache.writeQuery
to update my cache after a mutation, and it just is not updating the cache. The updates just aren't in there.
This is in my update()
callback from the useMutation
:
const userData = copy(cache.readQuery({
query: GET_USER
}))
userData.me.categories.push(newCategory)
cache.writeQuery({
query: GET_USER,
data: userData
})
console.log('New category shows up here:')
console.log(userData.me.categories.map(category => category.id))
const _userData = copy(cache.readQuery({
query: GET_USER,
}))
console.log('New category is not in here:')
console.log(_userData.me.categories.map(category => category.id))
I'm deep-cloning my user data, and simply pushing onto its categories. It just doesn't want to store the updated data. It's clearly doing something, insofar as I can mutate all my existing categories and change their names etc, it just will not add a new one.
What can I try next?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论