1- /* eslint no-console: 0 */
21import React from 'react'
32import ReactDOM from 'react-dom'
4- import { ApolloClient } from 'apollo-client'
5- import { InMemoryCache } from 'apollo-cache-inmemory'
6- import { HttpLink } from 'apollo-link-http'
7- import gql from "graphql-tag"
8- import { BrowserRouter as Router , Route , Switch } from 'react-router-dom'
3+ import { ApolloProvider } from 'react-apollo'
4+ import { BrowserRouter , Route , Switch } from 'react-router-dom'
95import StartPage from './pages/StartPage'
106import DemoPage from './pages/DemoPage'
117import { startPageRoute , demoPageRoute } from './routes'
128import './index.scss'
9+ import client from './graphql/client'
1310
1411function addDivWithIdToBody ( ) {
1512 const appElement = document . createElement ( "div" )
@@ -19,37 +16,15 @@ function addDivWithIdToBody() {
1916
2017addDivWithIdToBody ( )
2118
22- const cache = new InMemoryCache ( )
23-
24- const client = new ApolloClient ( {
25- cache,
26- link : new HttpLink ( {
27- uri : 'https://streams-server.herokuapp.com/graphql' ,
28- } ) ,
29- } )
30-
31- client
32- . query ( {
33- query : gql `
34- query GetStations {
35- stations(pageSize: 3) {
36- stations {
37- id
38- text
39- }
40- }
41- }
42- ` ,
43- } )
44- . then ( result => console . log ( '~result~' , result ) )
45-
4619const App = ( ) => (
47- < Router >
48- < Switch >
49- < Route exact path = { startPageRoute } component = { StartPage } />
50- < Route exact path = { demoPageRoute } component = { DemoPage } />
51- </ Switch >
52- </ Router >
20+ < BrowserRouter >
21+ < ApolloProvider client = { client } >
22+ < Switch >
23+ < Route exact path = { startPageRoute } component = { StartPage } />
24+ < Route exact path = { demoPageRoute } component = { DemoPage } />
25+ </ Switch >
26+ </ ApolloProvider >
27+ </ BrowserRouter >
5328)
5429
5530ReactDOM . render ( < App /> , document . getElementById ( 'app' ) )
0 commit comments