Fork me on GitHub
#fulcro
<
2021-10-27
>
Thomas Moerman10:10:48

Cool talk by Malcolm Sparks, strikes close to the RAD philosophy: https://youtu.be/jTpP4WsUgfQ?t=1228

Hukka11:10:35

Just the last three minutes?

cjsauer22:10:25

Can I use union queries if the key I want to switch is not the entity’s :ident? To clarify, lots of my entities share a common :db/id that they use for their :ident, but I have a component that uses a case expression on a different key in order to decide what to render. It seems that union queries assume it’s the ident that is the switching key…

tony.kay02:10:34

No. Union queries have no other information available BUT the ident during denormalization, and they have to use that to decide which of the union elements is the subquery. Using native IDs in the data model is fine, but it is better to give each ID an entity-specific name at the resolver layer. You could also give each entity a "type" field of some kind, and generate idents that way (use the type field as the first element of the idents).

cjsauer12:10:28

That makes sense. Thanks Tony.

tony.kay16:10:50

BTW: a concat of get-query will almost never do what you want. The resulting query will have metadata that only knows the ident function of the container, which will break normalization in 99% of cases...e.g. won't do the right thing if you were to load or merge using that component as the normalizing component

cjsauer21:10:29

Oh that’s good to know, thanks for the heads up. I ended up solving it at the resolver layer as you suggested.

cjsauer22:10:34

I got this working:

:query (fn [] (concat (comp/get-query EntityA) (comp/get-query EntityB) ...))
But it feels less than ideal (lots of wasted query computing)

cjsauer22:10:50

I can see why it works this way. Bit of a chicken-or-the-egg problem, or what’s available and when. Wondering if there’s a better way than the above.

cjsauer22:10:40

(The answer might be “don’t have everything use :db/id”. This just happened to be the most convenient way to import this data into Fulcro.)