Fork me on GitHub
#fulcro
<
2020-07-02
>
zilti00:07:19

How is RAD Datomic handling enums internally? I have an enum and want to get the value, and happen to use d/fetch, but that gives me back a {:db/id 17592186045420} instead of the keyword I'd expect

zhuxun219:07:03

How should I write the query when I have two different ui representations for the same entity in the same parent ui? Let's say I have PersonDetail and PersonProfile under the same parent Account. What should I put in :account/person?

(defsc PersonDetail [..] {:ident :person/id ...} ...)
(defsc PersonProfile [..] {:ident :person/id ...} ...)

(defsc Account [_ {:account/keys [person]}]
  {:ident :account/id
   :query [:account/id {:account/person (comp/get-query ???)}]}
  (div
    (ui-person-detail person)
    (ui-person-profile person)))

tony.kay21:07:07

See union queries in the book

tony.kay21:07:43

BUT if they have the same ident, then you’d join each with its own edge

tony.kay21:07:57

and then just show whichever makes sense. Loading would be a separate issue

tony.kay21:07:20

{:account/profile (get-query Profile) :account/detail (get-query Detail)}

zhuxun221:07:37

Thanks. I thought about having separate edges, but got stuck on how to easily load them in a nested query

zhuxun221:07:36

Because now I have a discrepancy between the server-side schema and the client-side query structure. Feels like it's going to be something I have to constantly be conscious about.

zhuxun221:07:33

But let me give it a try and see if it's going to be as much of a nuisance as I imagined

tony.kay22:07:04

a person should just have resolvers…the server doesn’t care what the UI shape is. You probably want to “load” whichever screen you route to to make sure the data is up-to-date.

tony.kay22:07:30

it’s exactly what RAD does: you could have a dozen different forms for a person. When you route to it, you load it.

tony.kay22:07:05

I would not do it the way you’re doing it, because you’re re-inventing “routing”. I’d suggest playing with RAD and looking at how that all integrates togther rather that writing one-offs like this

👍 3
zhuxun219:07:00

Maybe an manually written ui-less query?

zhuxun219:07:32

Is there a way to automatically merge two queries?

zhuxun219:07:48

Like {:account/person (comp/union-query PersonDetail PersonProfile)}

magra19:07:14

Hi, my app started out as the template for 3 some time ago. Now I started using link queries [:some-data '_] as I understand them from the book. They work fine and like a charm. The Query shows up on the server though. Is this intended/normal behavior?

tony.kay21:07:35

yes. you can use global query transform to alter what gets elided from server queries.

magra16:07:14

Thank you!