man, Pathom union query is kicking my ass
So far i understood that the Fulcro syntax for union queries is invalid for Pathom, as queries should always be specified as a vector
It’s a vector where the union item is a map, right?
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
Yeah, so I'm wondering about the correct approach:
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...
}])
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
I'm guessing that by wrapping the union in a vector, Fulcro normalization gets confused
Any pointers would be super appreciated :thumbsup::skin-tone-3:
df/load! with update-query
perhaps, I'll look into it further
Have you looked at the query section of the book?
What you’ve got looks right, excepting if you don’t have idents defined, that might cause issues
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
2. yes hold on, i'll post what i have so far
{: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))))))}
Hmm...that’s a bit outside my understanding of Fulcro at the moment. Hopefully someone else who knows more can help.
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.
Don't worry, chances are real that i've tied myself in a knot and that the problem isn't a fulcro one
Hopefully that helps narrow down what might be going on for you.
thanks for "rubber ducking" 😉
👍:skin-tone-2:🙂