This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-29
Channels
- # announcements (6)
- # babashka-sci-dev (15)
- # beginners (46)
- # calva (1)
- # clj-kondo (1)
- # clojure-australia (2)
- # clojure-europe (10)
- # clojure-uk (4)
- # clojured (3)
- # clojurescript (16)
- # fulcro (6)
- # helix (1)
- # hyperfiddle (8)
- # instaparse (28)
- # joyride (33)
- # malli (17)
- # off-topic (13)
- # pedestal (3)
- # portal (5)
- # react (1)
- # sci (1)
- # sql (6)
- # vim (1)
I have the following:
(comp/defsc Comp1
[_this props]
{:query [::foo/id
::foo/name
{::foo/things [::thing/id
::thing/name]}]
:ident ::foo/id})
(comp/defsc Comp2
[_this props]
{:query [::foo/id
::foo/some-other-top-level-field
{::foo/things [::thing/id
::thing/some-other-nested-field]}]
: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?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?
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 https://book.fulcrologic.com/#ResultMerge 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 https://blog.jakubholy.net/2020/fulcro-divergent-ui-data/#_a_data_entity_spread_across_multiple_sibling_components trying to implement it. Perhaps a mention of this caveat would be a helpful addition? Anyhow, thanks as always!
Thank you! I will have a look at improving it.