在 NUXT 中使用 vue-apollo 从 Vuex 商店访问 this.$apollo?
Access to this.$apollo from Vuex store with vue-apollo in NUXT?
我想将来自登录操作的用户存储在 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,
},
})
}
谢谢!
您应该可以像这样访问它:
export default {
actions: {
foo (store, payload) {
let client = this.app.apolloProvider.defaultClient
}
}
}
因为我在我的 nuxt apollo 插件中注入了 apolloProvider,
inject("apollo", apolloProvider);
然后在我的例子中,我使用
访问它
export default {
actions: {
foo (store, payload) {
let apolloClient = this.$apollo.defaultClient
}
}
}
我想将来自登录操作的用户存储在 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,
},
})
}
谢谢!
您应该可以像这样访问它:
export default {
actions: {
foo (store, payload) {
let client = this.app.apolloProvider.defaultClient
}
}
}
因为我在我的 nuxt apollo 插件中注入了 apolloProvider,
inject("apollo", apolloProvider);
然后在我的例子中,我使用
访问它export default {
actions: {
foo (store, payload) {
let apolloClient = this.$apollo.defaultClient
}
}
}