Fork me on GitHub
#fulcro
<
2020-10-17
>
Thomas Moerman14:10:21

man, Pathom union query is kicking my ass

Thomas Moerman14:10:58

So far i understood that the Fulcro syntax for union queries is invalid for Pathom, as queries should always be specified as a vector

futuro14:10:36

It’s a vector where the union item is a map, right?

futuro14:10:33

I’m not at my computer, but I remember it as something like that. The whole query is a vector and the union portion involves a map as an item in that vector

Thomas Moerman15:10:19

Yeah, so I'm wondering about the correct approach:

Thomas Moerman15:10:53

in the union component: are we supposed to specify the query like this? :

(defsc CaseProgressUnion
  [this props computed]
  {:query     (fn [] [{:nexus.case.image-annotation/id (comp/get-query ImageAnnotationCaseProgress)
                        ;; ...more types here...
                       }])

Thomas Moerman15:10:28

I kind of made it work like this, but it took some hackery in the :ident function, so I'm worried i'm missing the correct approach

Thomas Moerman15:10:35

I'm guessing that by wrapping the union in a vector, Fulcro normalization gets confused

Thomas Moerman15:10:55

Any pointers would be super appreciated :thumbsup::skin-tone-3:

Thomas Moerman18:10:09

df/load! with update-query perhaps, I'll look into it further

futuro18:10:17

Have you looked at the query section of the book?

futuro18:10:06

What you’ve got looks right, excepting if you don’t have idents defined, that might cause issues

Thomas Moerman18:10:36

1. yes, but those examples illustrate the union query mechanism for the fulcro db only, not the situation where the pathom backend also has to parse the union query, which is (I guess) where the trouble starts as Fulcro and Pathom handle union queries slightly differently

Thomas Moerman18:10:46

2. yes hold on, i'll post what i have so far

Thomas Moerman19:10:06

{:query (fn []
            ;; Pathom idiomatic union query -> map wrapped in a vector
            [{:nexus.case.image-annotation/id (comp/get-query ImageAnnotationCaseProgress)}]

            )
   :ident (fn []
            (log/info "union props:" props)
            (cond (contains? props :nexus.case.image-annotation/id)
                  (do
                    ;(log/spy :info "CaseProgressUnion.ident-fn:" props)
                    (let [case-props (get props :nexus.case.image-annotation/id)]
                      ;; HACK HACK HACK -> TODO -> why is this necessary??
                      (if (eql/ident? case-props)
                        case-props
                        (:nexus.case.image-annotation/id case-props))))))}

futuro19:10:50

Hmm...that’s a bit outside my understanding of Fulcro at the moment. Hopefully someone else who knows more can help.

futuro19:10:20

I’ll say that in my explorations of Fulcro, I’ve successfully used join queries with pathom, so I believe it is possible, and it was seamless.

Thomas Moerman19:10:26

Don't worry, chances are real that i've tied myself in a knot and that the problem isn't a fulcro one

futuro19:10:33

Hopefully that helps narrow down what might be going on for you.

Thomas Moerman19:10:56

thanks for "rubber ducking" 😉

futuro19:10:59

👍:skin-tone-2:🙂