Vue-apollo: Error in beforeCreate hook: "TypeError: Cannot read property 'defaultOptions' of undefined"

Created on 23 Oct 2017  路  2Comments  路  Source: vuejs/vue-apollo

I get this error when I include "Vue.use(VueApollo)" in my main.js

my apollo.js:

import Vue from "vue"
import VueApollo from "vue-apollo"
import { ApolloClient, createBatchingNetworkInterface } from "apollo-client"

Vue.use(VueApollo);

const apolloClient = new ApolloClient({
    networkInterface: createBatchingNetworkInterface({
        uri: "http://localhost:1234/graphql"
    }),
    connectToDevTools: true
});

let apollo = new VueApollo({
    defaultClient: apolloClient
});

export default apollo

my main.js:

import Vue from "vue"
import App from "components/app"
import axios from "axios"
import router from "./router"
import apollo from "./apollo"

Vue.prototype.$http = axios;

const app = new Vue({
    router,
    apollo,
    ...App
});

export {
    app,
    apollo,
    router
}

What am I doing wrong?

Notes:
I am using the latest version of all packages.
I already tried cleaning npm cache and reinstalling everything.

Most helpful comment

It should be apolloProvider:

const app = new Vue({
    router,
    apolloProvider: apollo,
    ...App
});

All 2 comments

It should be apolloProvider:

const app = new Vue({
    router,
    apolloProvider: apollo,
    ...App
});

I am having the same issue, provide: apollo.provide() does not solve it

Was this page helpful?
0 / 5 - 0 ratings