pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
yenda 2020-05-17T09:00:24.034700Z

the union-query example works with a parser but not with parallel-parser

yenda 2020-05-17T09:28:26.035400Z

async-parser: {:search [{} {} {}]}
parallel-parser: {:search []}
parser: {:search [{:user/name Jack Sparrow} {:movie/title Ted} {:book/title The Joy of Clojure}]}

yenda 2020-05-17T12:23:02.036100Z

So far the only solution I found was to make a reader instead of a resolver:

(def user-notifications
  {:user/notifications
   (fn [env]
     (go-catch
        (<! (join-seq-parallel (assoc env
                                      ::p/union-path
                                      (fn [{:keys [query] :as env}]
                                        (let [e (p/entity env)]
                                          (:notification/type e))))
                               n)))))})

yenda 2020-05-17T12:23:31.036600Z

and to redefine join-seq-parallel so that it doesn't check if the query is a vector

wilkerlucio 2020-05-17T18:40:02.037Z

@yenda thanks for the report, looking into it now

wilkerlucio 2020-05-17T20:07:32.037400Z

@yenda fixed by: https://github.com/wilkerlucio/pathom/pull/161 going to release alpha-8 soon

wilkerlucio 2020-05-17T20:13:08.037800Z

also add new docs on unions + connect: https://wilkerlucio.github.io/pathom/v2/pathom/2.2.0/connect/resolvers.html#_union_queries

yenda 2020-05-17T20:24:51.038700Z

nice thanks! There is no solution for when you have a :type key for instance, because there isn't really any field unique to the entity?

wilkerlucio 2020-05-17T21:51:27.038800Z

you can still use that, by overwriting the ::p/union-path on the pathom env, this can be a (fn [env]) so you have full control over what branch to pick