-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
45 lines (39 loc) · 988 Bytes
/
App.js
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
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React from 'react';
import { ApolloProvider } from '@apollo/react-hooks';
import { HttpLink, InMemoryCache, ApolloClient } from 'apollo-boost';
import Navigator from './Navigator';
import { setContext } from 'apollo-link-context';
import { getToken } from './loginUtils';
const authLink = setContext(async (req, { headers }) => {
const token = await getToken();
return {
...headers,
headers: {
authorization: token ? `Bearer ${token}` : null,
},
};
});
const httpLink = new HttpLink({
uri: 'https://api.graph.cool/simple/v1/cjzwmuzb920gm0154ypyrmc98',
});
const link = authLink.concat(httpLink);
const client = new ApolloClient({
link,
cache: new InMemoryCache(),
});
export default class App extends React.Component {
render() {
return (
<ApolloProvider client={client}>
<Navigator />
</ApolloProvider>
);
}
}