cantierecreativo/redux-bees

How do people handle different api calls updating the same entity

Opened this issue · 1 comments

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

  • post 1
    • comments array
  • post 2
    • comments array
  • post 3
    • comments array

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

  • post 1
    • comments array
  • post 2
    • author
  • post 3
    comments array

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.

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.