vlcn-orm icon indicating copy to clipboard operation
vlcn-orm copied to clipboard

reactive queries and field edges

Open tantaman opened this issue 2 years ago • 0 comments

When traversing from a root node through a field edge, updates to the field edge do not correctly update the reactive query.

foo.queryBar().genLive()
foo.update({
  barId: newId
});

new bars won't be received as barId is encoded by value in the query.

Few options:

  1. live queries rely on a "query provider" function that is re-run to regenerate the query and re-capture variables This means the live query api must change quite a bit. To something like: makeLive(() => foo.queryBar());
  2. queryBar dynamically binds the barId in the query... So when it is re-run it is reading the latest barId from foo. This works but vastly changes the semantics of queries and maybe makes the unpredictable? If anyone ever saves a query then its results could change depending on when it is invoked... Queries are thus no longer immutable either. A query's behavior could change due to random other pieces of code mucking with unrelated objects.

Option (1) sounds like the right path. Too much spooky action at a distance in option (2).

tantaman avatar Sep 27 '22 14:09 tantaman