vue-apollo suddenly not being triggered by vue

Created on 23 Feb 2018  路  9Comments  路  Source: vuejs/vue-apollo

Hi, please help! I tried updating from 'alpha.3 to 'beta.4' this morning, and things went wrong. I restored from backup, deleted node_modules and reinstalled, but I still have the problem.

It seems that Vue is not triggering any apollo query in my app. I have tried to find a way to set a breakpoint inside vue-apollo somewhere to try and debug, but I can't find a suitable place to place the breakpoint.

Please can you give me some advice on how to find the problem?

I'm back on 'alpha.3', but the problem persists. It's obviously something app-wide, since no query works anywhere. I did not change any vue-apollo configuration in my code.

There are no msgs in the console, and when I try to use the Chrome Apollo devtool, I get an error msg in 'backend.js', about the store being undefined. GraphiQL queries to my backend work fine.

I'm at a total loss here, I can't find a place to drive a wedge in to find the problem.
I'm on the latest vue-cli, node and npm. Nothing else changed except my attempt to move to beta 4, and then going back to alpha 3.

I would really appreciate any thoughts on the problem!

Most helpful comment

Try this:

export default ({ app, Vue }) => {
  Vue.use(VueApollo)
  app.provide = apolloProvider.provide()
}

All 9 comments

I did not change any vue-apollo configuration in my code.

I think that's the problem. https://github.com/Akryum/vue-apollo/releases/tag/v3.0.0-beta.1

wow, what amazing response, thank you! I'll try that immediately.

Hmm, not so easy. I'm using Quasar framework for Vue (latest 0.15.1 release). It uses plugins to register components, like this in (generated - means I can't change that file) entry.js :

const app = {
  el: '#q-app',
  router,
store,
  ...App
}

const plugins = []

import pluginI18n from 'src/plugins/i18n'
plugins.push(pluginI18n)

import pluginAxios from 'src/plugins/axios'
plugins.push(pluginAxios)

import pluginApollo from 'src/plugins/apollo'
plugins.push(pluginApollo)

import pluginVuelidate from 'src/plugins/vuelidate'
plugins.push(pluginVuelidate)

plugins.forEach(plugin => plugin({ app, router, store, Vue }))

/* eslint-disable no-new */
new Vue(app)

and my plugin looks like this:

const apolloClient = new ApolloClient({
  link: httpLink,
  fetch: fetch,
  // cache: new InMemoryCache({ fragmentMatcher }),
  cache: new InMemoryCache(),
  connectToDevTools: process.env.NODE_ENV !== 'production'
})

const apolloProvider = new VueApollo({
  defaultClient: apolloClient,
  clients: { default: apolloClient },
  defaultOptions: {
    $loadingKey: 'loading'
  },

export default ({ app, Vue }) => {
  Vue.use(VueApollo)
  app.apolloProvider = apolloProvider
}

I don't seem to have a way to specify the 'provider:'

I'm back on alpha.3 now. There are no 'graphql' queries being sent (in the network log). It's like apollo is just not being called, and I can't understand why. I must have 65 different apollo queries in my app, and suddenly not a single one is working. Something changed on my system, but even after I restoring from backups and reinstalling 'node_modules', the problem remains.

I know this is not your problem, but I appreciate any help. I'm hoping you can point me to a way to insert a 'debugger' statement in the vue-apollo query code in my 'node_modules' so that I can try to figure out what's happening

To be clear, I'm back on 'Alpha.3', which does not use the new 'provide:' approach. This was working well.

Ok, my bad, I have managed to get it working again on alpha.3. I will have to figure out how to work with the beta.1 approach. Not quite sure what happened there, but thanks for the help, and thank you again for vue-apollo I love it!

Try this:

export default ({ app, Vue }) => {
  Vue.use(VueApollo)
  app.provide = apolloProvider.provide()
}

Ok, I'll give it a shot, thank you! I like to stay up to date with the latest version of vue-apollo, because it's just amazing. Thank you again for the hard work you have done to make this possible.

BTW, if you haven't heard about Quasar Framework, you might like it. A lot. http://quasar-framework.org/

Yes, that works perfectly, thank you! I'm now on beta.4, and I'm never going to look back :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chadwtaylor picture chadwtaylor  路  3Comments

AruXc picture AruXc  路  4Comments

jakub300 picture jakub300  路  4Comments

alsofronie picture alsofronie  路  3Comments

wangxiangyao picture wangxiangyao  路  4Comments