Fork me on GitHub
#pathom
<
2021-11-24
>
Jakub Holý (HolyJak)11:11:51

A question about P3 and error handling. According to https://pathom3.wsscode.com/docs/error-handling#optionality, this

(p.eql/process
    (pci/register
      (pco/resolver 'error
        {::pco/output [:error]}
        (fn [_ _]
          (throw (ex-info "Deu ruim." {})))))
    [(pco/? :error)]))
should throw an exception but returns {} using Pathom 2021.07.10-alpha Why? Changing the query to [:error ::pcr/attribute-errors] does not influence the result.

wilkerlucio12:11:35

I just tried to reproduce but I see an error when I run this code here :thinking_face:

wilkerlucio12:11:41

but try upgrading, latest is 2021.11.16-alpha

wilkerlucio12:11:56

(I tested over the main branch here)

Jakub Holý (HolyJak)08:11:43

I have changed to that version and now: 1. The query [(pco/? :error)] returns nil 2. The query [:error] throws an exception

zeitstein22:11:11

I noticed something while transitioning my resolvers from Pathom 2 to 3. Consider the following resolvers:

(pco/defresolver main-tree-resolver []
  {::pco/output [{:side [:root/id {:root/list [:id]}]}]}
  {:main {:root/id :main :root/list [{:id 1} {:id 2}]}})  ; {:id 1}

(pco/defresolver side-tree-resolver []
  {::pco/output [{:side [:root/id {:root/list [:id]}]}]}
  {:side {:root/id :side :root/list [[:id 1] [:id 2]]}})  ; [:id 1]

(pco/defresolver id-resolver [{id :id}]
  {::pco/output [:id :text]}
  (...)
Running the EQL query
[{:main [:root/id {:root/list [:id :text]}]}]
resolves everything, while the same query for :side doesn't resolve elements from :root/list. Which is fine (though, not how it worked for Pathom 2). But consider that main-tree-resolver doesn't return a :root/list vector of Fulcro-style idents, so it could not feed the client database. So, I guess I'm making a mistake somewhere?

wilkerlucio22:11:13

the example here has something wrong, the main-tree-resolver output has :side at root

wilkerlucio22:11:56

but about [:id 1], to Pathom that's a vector with two elements, the concept of ident pointer like that is Fulcro only, in Pathom each item must always be a map with the available context (like at the main-tree-resolver values)

wilkerlucio22:11:41

seems strange that this works on P2, the premise is the same there, maybe some plugins, or using some custom reader could change the behavior, but I dont expect that work by default

zeitstein22:11:41

> the example here has something wrong, the `main-tree-resolver` output has `:side` at root Copying error, sorry. This was the parser I used for P2 with Fulcro's mock-http-server:

(def pathom-parser
  (p/parallel-parser
   {::p/env     {::p/reader [p/map-reader
                             pc/parallel-reader
                             pc/open-ident-reader]}
    ::p/mutate  pc/mutate-async
    ::p/plugins [(pc/connect-plugin {::pc/register resolvers})
                 p/error-handler-plugin
                 p/request-cache-plugin
                 (p/post-process-parser-plugin p/elide-not-found)]}))

zeitstein22:11:11

Anyway, thanks for clearing it up.

zeitstein23:11:39

Btw, Pathom 3 docs provide a very good introduction. Good job!

🙏 1