-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copying query result into another point in store. #525
Comments
@tomitrescak What's the specific use-case you have for this? It seems to me that this isn't a feature that should be in the core of apollo client, but that instead we should make it easy to configure or replace the mechanisms that interact with the store, which would then also let us support other stores like MobX or ngrx. |
I'm using this with optimistic updates. But with the latest apollo-react I am using this less and less as new version has optimistic updates and query manipulation. Yet, there are still use cases when I need to remap the query result to a different point in store when I'm doing more complex forms and I need query result for various UI updates through redux store. |
Our use-case is to duplicate data to a different data structure for faster reads and less re-rendering (e. g. one reducers manages a hash map of id<->shift and another startDate<->shift). At the moment we also take what we need from QUERY_RESULT, but it relies on string splitting and is therefore a bit cumbersome. I believe that a more general way to hook into the store management of apollo would solve this use-case very nicely 👍 |
This should be possible with #921 and/or result/reducers. It's not as straight forward as you might like, but I think together with custom redux reducers it's good enough for now. |
In alignment to discussion in #98 this problem seems not to be tackled yet. Is there a possibility to redirect or store query results in another point in the redux store.
I currently have it working my way by intercepting apollo actions in my reducers and copying it into the store there. Yet, this approach duplicates data (which may be alright I guess).
Reducer
Helpers
Would this be a valid approach, or is there something better?
There is a set of tools at https://github.com/tomitrescak/apollo-redux-tools you can check out that is currently heavily undocumented, but am working on documentation today.
The text was updated successfully, but these errors were encountered: