Fork me on GitHub
#pathom
<
2022-07-25
>
Quentin Le Guennec08:07:18

I got a resolver in pathom 3 which is correctly parsed and resolved in the repl but the same resolver with the same input doesn't resolve when I parse it in the definition of a resolver. Could this be a bug?

souenzzo12:07:26

Can you provide a example, like this one:

(let [;; a resolver
      a (pco/resolver `a
          {::pco/output [:a]}
          (fn [_ _]
            {:a 42}))
      env (pci/register [a])]
  ;; that is correctly parsed in parser
  (prn (p.eql/process env [:a]))
  ;; but not when I use the definition
  (prn  (a {} {})))

Quentin Le Guennec18:07:25

Nope not exactly. Sorry if this is unclear. This works fine: (parser {} [{[:person/id "id"] [:a/name]}]) But somehow if I use the same in here:

(pco/defresolver test  [{:keys [parser] :as env} {:person/keys [id]}]
  {::pco/input  [:person/id]
   ::pco/output [:person/test]}
  {:person/test
   (parser env [{[:person/id id] [:a/name]}])})
It resolves to nothing. The inputs are exactly the same in both cases.

Quentin Le Guennec18:07:49

I should point out that the test resolver has ::pco/batch? true in the real code.

souenzzo19:07:48

@U0111PVCS8P by running this code

(let [a (pco/resolver `a
          {::pco/output [:a]}
          (fn [{:keys [parser]} _]
            {:a (nil? parser)}))
      env (pci/register [a])]
  (p.eql/process env [:a]))
=> {:a true}
I can see that there is no :parser key in the env pathom3 do no have parser concept You should call process explicitly
(pco/defresolver test  [env {:person/keys [id]}]
  {::pco/input  [:person/id]
   ::pco/output [:person/test]}
  {:person/test (p.eql/process env [{[:person/id id] [:a/name]}])})

Quentin Le Guennec19:07:52

@U2J4FRT2T Thanks for your answer. Same behavior with p.eql/process, tho. I think parser is something fulcro injects.

Quentin Le Guennec19:07:26

in the env map: :parser #function[com.wsscode.pathom3.interface.eql/process]

souenzzo19:07:45

(pco/defresolver test  [{:keys [parser] :as env} {:person/keys [id]}]
  {::pco/input  [:person/id]
   ::pco/output [:person/test]}
  (try
    (println [:start id])
    (let [return (parser env [{[:person/id id] [:a/name]}])]
      (println [:ok id return])
      {:person/test return})
    (catch Throwable ex 
      (println [:fail id ex])
      (throw ex))))

Quentin Le Guennec19:07:05

I think I’m getting more information if I remove the lenient mode injected by fulcro.

Quentin Le Guennec22:07:40

I asked in the fulcro channel as it seems more fulcro than pathom related.

roklenarcic21:07:09

in eql AST what is the difference between :key and :dispatch-key