I'm trying to get a union resolver/query to work but have failed so far. I have made a simple example with my best attempt so far, and I would be really happy if someone could point out what I'm doing wrong 🙂 Is it correct that union resolvers are specified just as a normal output join, and the union "logic" is present just in the query? I'm on pathom version 2.2.30.
I think I've figured out what I'm doing wrong now, union resolvers can't be "to-many" (or can they?).
By introducing the concept of a single "search-result", the resolver now looks like:
(pc/defresolver search-resolver
[_ {:keys [search/term]}]
{::pc/input #{:search/term}
::pc/output [{:search/results
[{:search/result [:image/id :video/id]}]}]}
{:search/results [{:search/result {:image/id 1}}
{:search/result {:video/id 3}}]})
The query:
(async/<!! (parser {} [{[:search/term "my-search-term"]
[{:search/results
[{:search/result
{:image/id [:image/name]
:video/id [:video/title]}}]}]}]))
;; => {[:search/term "my-search-term"] #:search{:results [#:search{:result #:image{:name "Red flower"}}
;; #:search{:result #:video{:title "A day in life"}}]}}
Success!