我想将来自登录操作的用户存储在vuex存储中。但是无法访问this.$apollo
。
export const actions = {
UPSERT_USER({ commit }, { authUser, claims }) {
this.$apollo
.mutate({
mutation: UPSERT_USER_MUTATION,
variables: {
id: user.uid,
email: user.email,
name: user.name,
picture: user.picture,
},
})
}
谢谢!
答案 0 :(得分:3)
您应该可以这样访问它:
export default {
actions: {
foo (store, payload) {
let client = this.app.apolloProvider.defaultClient
}
}
}
答案 1 :(得分:1)
因为我在我的 nuxt apollo 插件中注入了 apolloProvider,
inject("apollo", apolloProvider);
然后在我的情况下,我使用,
export default {
actions: {
foo (store, payload) {
let apolloClient = this.$apollo.defaultClient
}
}
}