asd

Javascript code posted
created at 27 Aug 18:18, updated at 01 Sep 12:57

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { ApolloClient } from 'apollo-client'
import { HttpLink } from 'apollo-link-http'
import { ApolloLink, concat } from 'apollo-link'
import { InMemoryCache } from 'apollo-cache-inmemory'
import Vue from 'vue'
import vSelect from 'vue-select'
import VueApollo from 'vue-apollo'
import App from './App.vue'
import router from './router'
import axios from './backend/vue-axios'
import BootstrapVue from 'bootstrap-vue'
import Config from './config.js'
import './registerServiceWorker'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'

Vue.config.productionTip = false

Vue.use(BootstrapVue)
Vue.component('v-select', vSelect)

const httpLink = new HttpLink({
  uri: Config.HTTP_LINK_URL
})

const authMiddleware = new ApolloLink((operation, forward) => {

  operation.setContext({
    headers: {
      "Authorization": "Bearer " + localStorage.token
    }
  });

  return forward(operation);
})

const apolloClient = new ApolloClient({
  link: concat(authMiddleware, httpLink),
  cache: new InMemoryCache({ addTypename: false }),
  connectToDevTools: true
})

Vue.use(VueApollo)

const apolloProvider = new VueApollo({
  defaultClient: apolloClient,
  defaultOptions: {
    $loadingKey: 'loading'
  }
})

new Vue({
  provide: apolloProvider.provide(),
  router,
  axios,
  render: h => h(App)
}).$mount('#app')
1.38 KB in 3 ms with coderay