-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
65 lines (52 loc) · 1.82 KB
/
index.js
File metadata and controls
65 lines (52 loc) · 1.82 KB
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
62
63
64
65
import React from "react"
import ReactDOM from "react-dom"
import { ApolloClient } from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { HttpLink } from 'apollo-link-http';
import { onError } from 'apollo-link-error';
import { ApolloLink } from 'apollo-link';
import { ApolloProvider } from 'react-apollo'
import "./index.css"
import { BrowserRouter, Route } from "react-router-dom"
import Navigation from "./components/navigation"
import newHousehold from "./components/newHousehold"
import households from "./components/households"
import { Button, Container, Divider, Grid, Header, Image, Menu, Segment } from 'semantic-ui-react'
// Pass your GraphQL endpoint to uri
// const client = new ApolloClient({ uri: 'https://api.graph.cool/simple/v1/cjfziljc40ovj0152gg9hr206' });
const client = new ApolloClient({
link: ApolloLink.from([
onError(({ graphQLErrors, networkError }) => {
if (graphQLErrors)
graphQLErrors.map(({ message, locations, path }) =>
console.log(
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`,
),
);
if (networkError) console.log(`[Network error]: ${networkError}`);
}),
new HttpLink({
uri: 'https://api.graph.cool/simple/v1/cjfziljc40ovj0152gg9hr206'
})
]),
cache: new InMemoryCache()
});
const ApolloApp = AppComponent => (
<ApolloProvider client={client}>
<AppComponent />
</ApolloProvider>
);
ReactDOM.render(
<Container style={{ marginTop: '3em' }}>
<ApolloProvider client={client}>
<BrowserRouter>
<div>
<Navigation />
<Route path="/newhousehold" exact component={newHousehold}/>
<Route path="/households" exact component={households} />
</div>
</BrowserRouter>
</ApolloProvider>
</Container>,
document.getElementById("root")
);