apollographql / react-apollo

:recycle: React integration for Apollo Client
https://www.apollographql.com/docs/react/
MIT License
6.85k stars 787 forks source link

How to make the reducer works with ImmutableJs #159

Closed raymondsze closed 8 years ago

raymondsze commented 8 years ago

Not quite understand http://docs.apollostack.com/apollo-client/react.html#usage-with-immutable I follow the guideline but not works const store = createStore(combineReducers({ counter }), initialState); There is no reducer defined when create the store, how apollo client reducer works? I have this error Error: Existing store does not use apolloReducer for apollo

import { combineReducers } from 'redux-immutablejs';
import client from './client';

const reducer = combineReducers({
    apollo: client.reducer(),
  });
export default reducer;
jbaxleyiii commented 8 years ago

@raymondsze currently ImmutableJs only works for a store outside of apollo-client. The docs need to be more clear but essentially, if you have an ImmutableJs redux store, you can seperate it and not have apollo-client use that store (it will create its own store)

jbaxleyiii commented 8 years ago

closing this for now as its been more than two weeks without a response. Feel free to open again!

gajus commented 8 years ago

@jbaxleyiii why was this closed if there is no solution ... ? using a second store is just a workaround.

This could be an easy fix. All you need to do is to abstract the method used to get data from the state, e.g. such as this one:

https://github.com/apollostack/react-apollo/blob/4042b7e7366c51f05e185d8b298f3019f3adc178/src/graphql.tsx#L216

stubailo commented 8 years ago

There's actually a PR for that here: https://github.com/apollostack/apollo-client/pull/631