【发布时间】:2022-01-29 16:08:39
【问题描述】:
我通过 apollo 突变删除了页面中的一些资源:
async delete () {
await this.$apollo.mutate({
mutation: orderDelete,
variables: {
id: this.order.id
}
})
this.$emit('success')
}
这是
success
发射器触发的方法:
onOrderDeleted () {
this.closeModal('modalOrderDelete')
this.$nextTick(() => {
this.redirectToClient()
})
},
redirectToClient () {
this.$router.push({
name: 'clients.show',
params: { clientKey: this.clientKey }
})
}
这是发生的事情:当页面被重定向到
clients.show
时,即使我删除了它,订单仍然会显示,只有在我刷新整个页面时才会更新。
所以我想知道当我重定向到此页面时如何触发查询刷新? Apollo 可能将数据保存在缓存中而不是更新它,我不知道如何仅更新此特定查询的缓存,但所有这些都是以编程方式进行的,因为用户将通过 Vue Router 重定向。
注意:
clients.show
显示了一个订单列表,因此它应该更新删除我刚刚删除的订单的订单,但它并没有改变。