Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in beforeCreate hook: "TypeError: Cannot read property 'defaultOptions' of undefined" #131

Closed
ceferrari opened this issue Oct 23, 2017 · 2 comments

Comments

@ceferrari
Copy link

ceferrari commented Oct 23, 2017

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.

@Akryum
Copy link
Member

Akryum commented Oct 24, 2017

It should be apolloProvider:

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

@Akryum Akryum closed this as completed Oct 24, 2017
@MaestroJurko
Copy link

MaestroJurko commented May 9, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants