我想在我的apollo客户端中更新一个缓存的查询。通常,我会在发生突变后执行此操作,例如:
await this.$apollo.mutate({
mutation: gql`
mutation myMutation ($foo: String!) {
doSomething (foo: $foo) {
id
bar
}
}
`,
result: (store) => {
// Here I can access the apollo cached queries to update them
const foos = store.readQuery({
// ...
})
store.writeQuery( /* ... */)
}
但是如何从此result
函数外部访问同一商店?我尝试检查this.$apollo
,但似乎在任何地方都找不到readQuery
和writeQuery