Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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;
import { combineReducers, Reducer } from 'redux';
import client from './apolloClient';
export const rootReducer = combineReducers({
apollo: client.reducer() as Reducer<any>,
});
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