-
Notifications
You must be signed in to change notification settings - Fork 786
Make it easy to use Apollo with Redux directly #26
Comments
Yeah, I should write a post about this with a diagram. Basically, Apollo lives in Redux alongside your normal Redux data. It could be a separate store, but there are a lot of advantages to having exactly one store if you're using Redux in other parts of your app. Since the store format is normalized and relatively complex, most people won't want to interact with the store directly using Rather than shipping some helper functions that you can use inside You can easily keep using the normal Redux So if you're already using Redux, the steps to add Apollo to your app are:
|
Don't you think this is the same slippery slope Meteor did from the very beginning? Building out some custom library that you then have responsibility to maintain and therefore increase the potential surface area of issues? I personally think what would have been more appropriate would have been to provide helper functions so people have more control of their own Futures. |
Can you also ship those helpers so people can use mapStateToProps themselves? |
I think this library is far far smaller than the scope of Meteor so I don't think it's a huge problem, but it shouldn't be too hard to export those helpers! |
@abhiaiyer91 what helpers are you taking about? I'm happy to export anything you would like! We were able to switch out our existing redux react app using the steps @stubailo mentioned. Can you outline how you would rather use Apollo with your setup? |
OK so what about a design like this:
These all exist inside the client anyway, so it's not a lot of work! Then we just document how to use these. Personally I think most people will prefer a nice container like the one we're working on here, but why not have more freedom! |
Let's export the action types too, that's common for redux modules to do |
Something like this? |
Yeah, we need the Also, that needs to take in a queryId maybe? |
@stubailo I was thinking we could write that sync read method and use it with a normal query. This helper wouldnt actually call the query, only read whats in the store right? Otherwise that's a redux antipattern |
Fwiw, this feels like it would be 100% changes to the apollo-client, not this library. This one choose the wrapping of redux route |
Oh, I guess I was thinking that passing in
Agreed. |
Going to close it here - thanks for the suggestion, @abhiaiyer91! I think we'll keep this wrapper though if at least to use it internally. Going to start rewriting parts of Galaxy with this soon. |
Thanks for the quick replies on this guys! By all means I think the wrapper is great for people ! Don't get me wrong, but for devs or teams with more preference and need for fine grained control we much rather have the building blocks and we'll put together the interface ourselves! Thanks again! |
Please keep the wrapper. It is much easier for people like us who are starting on Apollo to test things out fast. |
@stubailo, did you have a chance to write a post regarding interacting with the Apollo Redux store using the Apollo connect wrapper? I'd really appreciate seeing an example of how to read/write to the store. |
@chris-guidry can you open a new issue please and add a description of what you're trying to accomplish? |
@chris-guidry Is Integrating with Redux the post you are looking for? |
@baerrach, nope, but thanks. I am not currently using Redux so I don't have an existing Redux store to integrate with, but there are a few instances where I need to save data for a few different components to use and would like to explore using the Apollo Redux store. Anyway, I will post a new issue describing that need more specifically. |
How does this play well with existing React Redux setups?
What was the design decision here?
Should you be more transparent about whats in this via standalone react redux. If i add this, do I have to remove my current module?
The text was updated successfully, but these errors were encountered: