-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
37 lines (32 loc) · 874 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
import React from "react";
import { ApolloProvider } from "react-apollo";
import { ApolloClient, HttpLink, InMemoryCache } from "apollo-boost";
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 httpLink = new HttpLink({
uri: "https://api.graph.cool/simple/v1/cjgr93mby1k870162a3c36e56"
});
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>
);
}
}