Static GitHub Issues

[2711] Cannot use Vue instance in @nuxtjs/apollo client setup

prev: External script support for CSP been merged in v1.2.0?
next: Hot Reloading Issue / This page could not be found

Hi,

I'm using apollo-module in my project.

I have use plugin to define vue token like this token.js

import Vue from 'vue'

export default ({ req, app }, inject) => {
  // Inject `token` key
  // -> app.$token
  // -> this.$token in vue components
  // -> this.$token in store actions/mutations
  inject('token', new Vue({
    data: () => ({
      token: process.server ? req.session.authToken : window.__NUXT__.state.auth.token
    }),
    methods: {
      set (token) {
        this.token = token
      },
      remove () {
        this.token = null
      }
    }
  }))
}

In my apollo client setup.

import things
...
export default (ctx) => {
  console.log(ctx.app) // I can see $token inside it
  console.log(ctx.app.$token) // get undefined
  const token = app.$token // undefined
  ....
}

If I console.log(ctx.app) I can see $token inside it. But I cannot access into $token image

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c2355">#c2355</a>)</em></sub></div>