@@ -2,29 +2,29 @@ import React from 'react'
2
2
import ReactDOM from 'react-dom'
3
3
import './styles/index.css'
4
4
import App from './components/App'
5
- import registerServiceWorker from './registerServiceWorker '
5
+ import * as serviceWorker from './serviceWorker '
6
6
import { ApolloProvider } from 'react-apollo'
7
7
import { ApolloClient } from 'apollo-client'
8
8
import { createHttpLink } from 'apollo-link-http'
9
9
import { InMemoryCache } from 'apollo-cache-inmemory'
10
10
import { BrowserRouter } from 'react-router-dom'
11
- import { AUTH_TOKEN } from './constants'
12
11
import { setContext } from 'apollo-link-context'
12
+ import { AUTH_TOKEN } from './constants'
13
13
import { split } from 'apollo-link'
14
14
import { WebSocketLink } from 'apollo-link-ws'
15
15
import { getMainDefinition } from 'apollo-utilities'
16
16
17
17
const httpLink = createHttpLink ( {
18
- uri : 'http://localhost:4000'
18
+ uri : 'http://localhost:4000' ,
19
19
} )
20
20
21
21
const authLink = setContext ( ( _ , { headers } ) => {
22
22
const token = localStorage . getItem ( AUTH_TOKEN )
23
23
return {
24
24
headers : {
25
25
...headers ,
26
- authorization : token ? `Bearer ${ token } ` : ''
27
- }
26
+ authorization : token ? `Bearer ${ token } ` : '' ,
27
+ } ,
28
28
}
29
29
} )
30
30
@@ -33,9 +33,9 @@ const wsLink = new WebSocketLink({
33
33
options : {
34
34
reconnect : true ,
35
35
connectionParams : {
36
- authToken : localStorage . getItem ( AUTH_TOKEN )
37
- }
38
- }
36
+ authToken : localStorage . getItem ( AUTH_TOKEN ) ,
37
+ } ,
38
+ } ,
39
39
} )
40
40
41
41
const link = split (
@@ -44,12 +44,12 @@ const link = split(
44
44
return kind === 'OperationDefinition' && operation === 'subscription'
45
45
} ,
46
46
wsLink ,
47
- authLink . concat ( httpLink )
47
+ authLink . concat ( httpLink ) ,
48
48
)
49
49
50
50
const client = new ApolloClient ( {
51
51
link,
52
- cache : new InMemoryCache ( )
52
+ cache : new InMemoryCache ( ) ,
53
53
} )
54
54
55
55
ReactDOM . render (
@@ -58,6 +58,6 @@ ReactDOM.render(
58
58
< App />
59
59
</ ApolloProvider >
60
60
</ BrowserRouter > ,
61
- document . getElementById ( 'root' )
61
+ document . getElementById ( 'root' ) ,
62
62
)
63
- registerServiceWorker ( )
63
+ serviceWorker . unregister ( )
0 commit comments