Skip to content

Instantly share code, notes, and snippets.

@Akryum
Created September 21, 2016 18:12
Show Gist options
  • Save Akryum/2fec1d9ae632b932918f6a185d5be154 to your computer and use it in GitHub Desktop.
Save Akryum/2fec1d9ae632b932918f6a185d5be154 to your computer and use it in GitHub Desktop.
vue-apollo configuration and app startup
import Vue from 'vue';
import App from './App.vue';
import ApolloClient, { createNetworkInterface, addTypename } from 'apollo-client';
import VueApollo from 'vue-apollo';
// Create the apollo client
const apolloClient = new ApolloClient({
networkInterface: createNetworkInterface({
uri: 'http://localhost:8080/graphql',
transportBatching: true,
}),
queryTransformer: addTypename,
dataIdFromObject: r => r.id,
});
// Install the vue plugin
// With the apollo client instance
Vue.use(VueApollo, {
apolloClient,
});
// Start the Vue app
new Vue({
el: '#app',
render: h => h(App)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment