Created
October 17, 2018 21:33
-
-
Save malgamves/727df43caa0e774b6e15e10184f84ee3 to your computer and use it in GitHub Desktop.
Vue GraphQL Main JavaScript file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 | |
import { ApolloClient } from 'apollo-client' | |
import { HttpLink } from 'apollo-link-http' | |
import { InMemoryCache } from 'apollo-cache-inmemory' | |
import Vue from 'vue' | |
// 2 | |
import VueApollo from 'vue-apollo' | |
import App from './App' | |
Vue.config.productionTip = false | |
// 3 | |
const httpLink = new HttpLink({ | |
// You should use an absolute URL here | |
uri: '<Your Hasura URI here>' | |
}) | |
// 4 | |
const apolloClient = new ApolloClient({ | |
link: httpLink, | |
cache: new InMemoryCache(), | |
connectToDevTools: true | |
}) | |
// 5 | |
Vue.use(VueApollo) | |
// 6 | |
const apolloProvider = new VueApollo({ | |
defaultClient: apolloClient, | |
defaultOptions: { | |
$loadingKey: 'loading' | |
} | |
}) | |
/* eslint-disable no-new */ | |
new Vue({ | |
el: '#app', | |
// 7 | |
apolloProvider, | |
render: h => h(App) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment