fulcro

Book: http://book.fulcrologic.com, Community Resources: https://fulcro-community.github.io/, RAD book at http://book.fulcrologic.com/RAD.html
Thomas Moerman 2020-10-17T14:11:21.317200Z

man, Pathom union query is kicking my ass

Thomas Moerman 2020-10-17T14:14:58.317900Z

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

futuro 2020-10-17T14:36:36.319700Z

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

futuro 2020-10-17T14:37:33.321300Z

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 Moerman 2020-10-17T15:40:19.324400Z

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

Thomas Moerman 2020-10-17T15:40:53.325100Z

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 Moerman 2020-10-17T15:42:28.326Z

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 Moerman 2020-10-17T15:47:35.326800Z

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

Thomas Moerman 2020-10-17T15:47:55.327300Z

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

Thomas Moerman 2020-10-17T18:19:09.328700Z

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

futuro 2020-10-17T18:37:17.329100Z

Have you looked at the query section of the book?

futuro 2020-10-17T18:38:06.330100Z

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

Thomas Moerman 2020-10-17T18:59:36.332200Z

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 Moerman 2020-10-17T18:59:46.332500Z

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

Thomas Moerman 2020-10-17T19:01:06.332800Z

{: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))))))}

futuro 2020-10-17T19:05:50.335Z

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

futuro 2020-10-17T19:07:20.337100Z

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 Moerman 2020-10-17T19:07:26.337500Z

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

futuro 2020-10-17T19:07:33.337800Z

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

Thomas Moerman 2020-10-17T19:07:56.338200Z

thanks for "rubber ducking" 😉

futuro 2020-10-17T19:14:59.338600Z

👍:skin-tone-2:🙂