Skip to content

Instantly share code, notes, and snippets.

@malgamves
Created October 17, 2018 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malgamves/727df43caa0e774b6e15e10184f84ee3 to your computer and use it in GitHub Desktop.
Save malgamves/727df43caa0e774b6e15e10184f84ee3 to your computer and use it in GitHub Desktop.
Vue GraphQL Main JavaScript file
// 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