-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
63 lines (48 loc) · 1.34 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import { Platform } from 'react-native';
import { ApolloProvider } from 'react-apollo';
import { ApolloClient } from 'apollo-client';
import { HttpLink } from 'apollo-link-http';
import { InMemoryCache } from "apollo-cache-inmemory";
import { setContext } from "apollo-link-context";
import Navigator from './Navigator';
import { getToken } from "./loginUtils";
const authLink = setContext(async (req, { headers }) => {
const token = await getToken();
return {
...headers,
headers: {
authorization: token ? `Bearer ${token}` : null
}
};
});
const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' +
'Cmd+D or shake for dev menu',
android: 'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
});
console.disableYellowBox = true;
type Props = {};
const httpLink = new HttpLink({
uri: "https://api.graph.cool/simple/v1/cjh4q0eer27dr0118zxron0bc"
});
const link = authLink.concat(httpLink);
const client = new ApolloClient({
link,
cache: new InMemoryCache()
});
export default class App extends Component<Props> {
render() {
return (
<ApolloProvider client={client}>
<Navigator />
</ApolloProvider>
);
}
}