apollographql / apollo-client

:rocket:  A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
https://apollographql.com/client
MIT License
19.38k stars 2.66k forks source link

Custom redux store with dev tools unable to connect #579

Closed sandervanhooft closed 8 years ago

sandervanhooft commented 8 years ago

Hi,

I've used the docs to integrate Apollo with a customized redux store.

console.log(store.getState()) works perfectly, however the redux dev tools now seem unable to connect. Any clue?

const networkInterface = createNetworkInterface(envconfig.GRAPHQL_SERVER)
const client = new ApolloClient({
  networkInterface,
})

const store = createStore(
  combineReducers({
    auth: authReducer,
    apollo: client.reducer(),
  }),
  applyMiddleware(
    client.middleware(),
    ReduxThunk.withExtraArgument(client)),
);

export default () => (
  <ApolloProvider store={store} client={client}>
    <Router history={browserHistory}>
      <Route path="/" component={Home} />
    </Router>
  </ApolloProvider>
)
stubailo commented 8 years ago

You need to connect your store to the dev tools: https://github.com/zalmoxisus/redux-devtools-extension#22-advanced-store-setup

Apollo Client does this automatically for the internal store, but when you make it yourself you need to do that configuration.

sandervanhooft commented 8 years ago

Works like a charm, thanks! I'd suggest to include this in the docs?

stubailo commented 8 years ago

I guess it's a Redux thing, not an Apollo thing - but I'd support just adding the dev tools middleware in that code snippet. We don't want to get too deep into documenting all of Redux, I think.

Mind submitting a PR?

sandervanhooft commented 8 years ago

@stubailo Done!