ruby-hyperloop / hyper-mesh

The project has moved to Hyperstack!! - Synchronization of active record models across multiple clients using Pusher, ActionCable, or Polling
https://hyperstack.org/
MIT License
22 stars 12 forks source link

Multiple queries breaks resolution of data. #42

Open sfcgeorge opened 6 years ago

sfcgeorge commented 6 years ago

I have 2 components A and B. Both cause queries. When queries for component B are batched in with component A then the placeholder values in A are never resolved. If I save and cause a hot reload of A the values are resolved (no additional queries, it just gets unstuck).

This happens whether the components are mounted separately, or one is inside the other.

I thought it might be to do with query splitting, aka when B requests data in 2 queries because it's getting attribute x for every record but attribute y conditionally. However by tweaking stuff I was able to get all of B's queries merged with A's in the second query and the issue persisted.

So, if B's query happens first and separately, and then A's happens, all is well. If some or all of B's data queries get merged with A's then A doesn't update it's placeholder "1" values.

The data in all cases is correct, regardless of which query it's in, and B updates perfectly whether the query is split, all up front, or all delayed. There are no errors. If a record is added and pushed then Hyperloop updates and A becomes unstuck.

Components

A is a list of vacancies with sub lists of conversations. It does one query to get the vacancies and totals, then another query to get the conversations and individual unread counts. It's these unread counts from the second query that sometimes get stuck as the placeholder 1 value.

B is a conversation, with Message sub component. It can either query everything in the first query, or if there is conditional display of some data then that subset is fetched in the second query. I believe this is the expected behaviour.

Good Queries

This is what it should look like:

screen shot 2017-10-20 at 17 59 37 screen shot 2017-10-20 at 17 40 31 screen shot 2017-10-20 at 17 40 51

Bad Queries

This is the stuck placeholders:

screen shot 2017-10-20 at 18 01 21

(the first query looks the same, except when you expand messages you see fewer fields are queried as they are now in query 2 as expected)

screen shot 2017-10-20 at 17 44 34 screen shot 2017-10-20 at 17 45 04