React-apollo: reduxRootSelector not found

Created on 12 Oct 2016  路  9Comments  路  Source: apollographql/react-apollo

I tried to follow the doc to integrate Apollo with an existing store, but encountered the error Existing store does not use apolloReducer. Please make sure the store is properly configured and "reduxRootSelector" is correctly specified.

The doc speaks of reduxRootKey whereas the error message speaks of reduxRootSelector. I have the feeling the code changed recently, and doc wasn't updated.

NB: I did add the apollo reducer as apollo: client.reducer() within my existing redux combineReducers. I then injected the store in ApolloProvider along with the client.

I tried adding reduxRootSelector: 'apollo' to the ApolloClient constructor, with same error message.

Most helpful comment

For case where immutable states in redux and some like redux-immutable is used selector must be like this:

new ApolloClient({
  reduxRootSelector: state => state.get('apollo'),
})

All 9 comments

reduxRootKey was deprecated, but it's still supported, so we'll need to update the docs. The rootSelector should be a function.

For your actual issue, are you using an external redux store? If so, are you constructing it with the apollo reducer as specified in the docs, and then using the apollo middleware?

Yeah, this sounds like you might not have added the middleware correctly.

Yes tried to integrate into react-boilerplate which has its own store, here it is in case you understand it 馃榿 https://github.com/sedubois/belong/compare/gql...apollo

A clarification for anyone else having this issue...

new ApolloClient({
    reduxRootSelector: state => state.apollo // your apollo reducer key
})

...is what needs to be added.

Thanks I'll keep it in mind if I play with that project again. (Note that my original issue was that I couldn't get Apollo to work, even when specifying neither reduxRootSelector nor reduxRootKey, so probably my issue was elsewhere.)

By the way I had briefly tried the suggestion with react-boilerplate but still had same issue. Actually a similar issue was created here: https://github.com/apollostack/apollo-client/issues/898

I have a fully worked app with RBP and Apollo, there is no any issues. I can send example of integration.

For case where immutable states in redux and some like redux-immutable is used selector must be like this:

new ApolloClient({
  reduxRootSelector: state => state.get('apollo'),
})
Was this page helpful?
0 / 5 - 0 ratings