Fork me on GitHub

I have the following:

(comp/defsc Comp1
  [_this props]
  {:query [::foo/id
           {::foo/things [::thing/id
   :ident ::foo/id})

(comp/defsc Comp2
  [_this props]
  {:query [::foo/id
           {::foo/things [::thing/id
   :ident ::foo/id})

(comp/defsc Parent
  [_this props]
  {:query [::foo/id
           {:>/c1 (comp/get-query Comp1)}
           {:>/c2 (comp/get-query Comp2)}]
   :ident ::foo/id})
The result is that ::thing/name is missing from Parent's props, but ::thing/some-other-nested-field is present along with ::thing/id. I guess whichever is the last of the siblings is the only one for which the nested query is used. All the top-level fields remain intact. More unusual is that the correct result is visible in Fulcro Inspect when checking the query, but it's not in props. Is there some explanation for this?

Jakub Holý (HolyJak)05:05:46

So the query sent to pathom is as expected? What about the result in the F.I. Network tab, does it also have the name? Is all the expected data inside client DB? What if you run manually db->tree?


@U0522TWDA I see now. In the client db it gets inserted at [::foo/id 1 ::foo/things] and the two different collections of ::foo/things do not get merged. So I guess the :>/... placeholder trick does not work for nested collections?

Jakub Holý (HolyJak)11:05:38

I think your formulation is incorrect. The "trick" does work and Pathom returns the data you want, as you want them, no? The problem is merging them into the client DB. Here it is good to know how Fulcro does that - review The key thing is: within an entity, data coming from different sources (eg loads) is merged together. But for values of properties of the entity, Fulcro cannot know what semantics apply and can only replace existing value with incoming. Since you use nested queries without normalization, both end up competing for the same property and one will override the other. If you make a separate Thing component with an ident and use get-query instead of inlining it then F. will be able to merge the multiple results together.


@U0522TWDA thanks very much for the thorough explanation and that link for background 🙏 I was following your guide trying to implement it. Perhaps a mention of this caveat would be a helpful addition? Anyhow, thanks as always!

Jakub Holý (HolyJak)11:05:28

Thank you! I will have a look at improving it.