使用 NUXT 中的 vue-apollo 从 Vuex 商店访问 this.$apollo? [英] Access to this.$apollo from Vuex store with vue-apollo in NUXT?

查看:29
本文介绍了使用 NUXT 中的 vue-apollo 从 Vuex 商店访问 this.$apollo?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 vuex 存储中存储来自登录操作的用户.但是无法访问this.$apollo.

I want to store the user that comes from the login on an action in the vuex store. But there is no access to 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,
          },
        })
    }

谢谢!

推荐答案

您应该能够像这样访问它:

You should be able to access it like this:

export default {
  actions: {
    foo (store, payload) {
      let client = this.app.apolloProvider.defaultClient
    }
  }
}

查看 https://github.com/nuxt-community/apollo-module

这篇关于使用 NUXT 中的 vue-apollo 从 Vuex 商店访问 this.$apollo?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆