Last active
February 18, 2017 18:04
-
-
Save RyanCCollins/32ac399958d0dc2a8c0dcb3449df2cd8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApolloClient, createNetworkInterface } from 'apollo-client'; | |
declare var window: { | |
__APOLLO_STATE__: string, | |
}; | |
const uri = process.env.API_URL || 'http://0.0.0.0:1338/api'; | |
const client = new ApolloClient({ | |
networkInterface: createNetworkInterface({ | |
uri, | |
}), | |
initialState: typeof window !== 'undefined' ? window.__APOLLO_STATE__ : null, // eslint-disable-line | |
ssrForceFetchDelay: 100, | |
}); | |
export default client; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { combineReducers, Reducer } from 'redux'; | |
import client from './apolloClient'; | |
export const rootReducer = combineReducers({ | |
apollo: client.reducer() as Reducer<any>, | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import { ApolloProvider } from 'react-apollo'; | |
import { Route, IndexRoute, Router as ReactRouter } from 'react-router'; | |
import client from './apolloClient'; | |
import store, { history } from './store'; | |
export const routes = ( | |
<Route path="/" component={App}> | |
<IndexRoute component={Home} /> | |
// routes go here | |
</Route> | |
); | |
const RouterApp = () => ( | |
<ApolloProvider store={store} client={client}> | |
<ReactRouter | |
onUpdate={logPage} | |
history={history} | |
routes={routes} | |
/> | |
</ApolloProvider> | |
); | |
export default RouterApp; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment