Skip to content

Instantly share code, notes, and snippets.

@galiazzi
Last active August 29, 2019 02:31
Show Gist options
  • Save galiazzi/f0f7a7940d4c7b8c8a34a07859cc743a to your computer and use it in GitHub Desktop.
Save galiazzi/f0f7a7940d4c7b8c8a34a07859cc743a to your computer and use it in GitHub Desktop.
Vue apollo
import Vue from "vue";
import VueApollo from "vue-apollo";
import ApolloClient from "apollo-boost";
Vue.use(VueApollo);
const token = "";
const apolloClient = new ApolloClient({
uri: "http://localhost:8000/graphql",
request: async operation => {
operation.setContext({
headers: {
authorization: token
}
}
)}
});
const apolloProvider = new VueApollo({
defaultClient: apolloClient
});
export default apolloProvider;
import Vue from "vue";
import App from "./App.vue";
import apolloProvider from "./apollo";
Vue.config.productionTip = false;
new Vue({
apolloProvider,
render: h => h(App)
}).$mount("#app");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment