cantierecreativo / redux-bees

A nice, short and declarative way to interact with JSON APIs
592 stars 41 forks source link

How do people handle different api calls updating the same entity #60

Open stueynet opened 6 years ago

stueynet commented 6 years ago

Currently the problem we have is that if we populate a list by making a query and including relationships, if somewhere else on the screen you may make a different call with different requested relationships, the top level entity is updated with the new relationship. So if your original query populated a table, for example, and accessed those relationships, things break down because now one entity in that list no longer has the relationships it originally had.

To simplify lets say you make a call to get posts with comments included. So you end up with

Get all posts with comments

entities

But on the same screen perhaps post 2 gets update via another query with a different requested shape like

Get a single individual post with author

So now your top level entities has:

entities

So the table that was originally populated with posts and something related to comments will break because suddenly comments disappear from one of those top level posts.

MrLeebo commented 6 years ago

I think you would either update your endpoints so that both include comments, or you would expose them as different types (e.g. short_posts and full_posts) so they don't collide with each other.