Hi, there is a related issue on Apollo-client repository, which we ask for help regarding using an Immutable structure with apollo-client.
I created my custom ImmutableCache as following:
import { Map, fromJS } from 'immutable';
export class ImmutableCache {
constructor(data = Map()) {
if (!(data instanceof Map)) {
this.data = fromJS(data);
} else {
this.data = data;
}
}
toObject() {
return this.data.toJS();
}
get(dataId: string) {
return this.data.get(dataId);
}
set(dataId, value) {
this.data = this.data.set(dataId, fromJS(value));
}
delete(dataId): void {
this.data = this.data.set(dataId, undefined);
}
clear(): void {
this.data = Map();
}
replace(newData) {
this.data = newData || Map();
}
}
export function immutableCache(seed) {
return new ImmutableCache(seed);
}
Then use it like that:
const cache = new InMemoryCache({
storeFactory: immutableCache,
});
However, the props are not populated in the component with the graphql response.
Could you please advice on how can i achieve this with react-apollo?
Thanks
Please ask questions on the slack channel or on stack overflow.