pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
Chicão 2021-02-17T16:45:01.284500Z

hi guys I'm trying to reproduce some error, but maybe I've been invoke mutations wrong, my example code is in this link https://gist.github.com/matheusfrancisco/09de37256dd94d8935e4d3be64adf7c9 , but

(pco/defresolver ex11 []
  {::pco/output [:ex.xico/http]}
  {:ex.xico/http (http/post "<https://url.org/1/post>" {:headers {:Content-Type "application/json"}})})

(pco/defmutation mutation-ex3 []
  {:ex.xico/cc (http/post "<https://url.org/2/post>" {:headers {:Content-Type "application/json"}})})

(def env1 (-&gt;
            (pci/register
              [ex11
               ex12
               mutation-ex3])
            (psm/with-error-mode ::psm/error-mode-loud)))
;; note in line 41 with psm/with-error-mode if I comment #_(psm/...) this line, the mutation will be work. 
;; with this line(41) uncommented the invoke at line 47 return an error, I put in first comment bellow

(:ex.xico/http (psm/smart-map env1))
(p.eql/process env1  [`(mutation-ex3)])
when I had been invoke my mutation i got this error
:data #:com.wsscode.pathom3.attribute{:attribute :async},
       :via [{:type clojure.lang.ExceptionInfo,
              :message "Can't find a path for :async",
              :data #:com.wsscode.pathom3.attribute{:attribute :async},
              :at [com.wsscode.pathom3.connect.runner.stats$attribute_error__25438 invokeStatic "stats.cljc" 73]}],
       :trace [[com.wsscode.pathom3.connect.runner.stats$attribute_error__25438 invokeStatic "stats.cljc" 73]
but, when I comment the (psm/with-error-mode ::psm/error-mode-loud) my mutations call the clj-http/post. may I don't know much about pathom, but should I don't use (psm/with-error-mode ..) actived with mudations?

nivekuil 2021-02-17T17:19:14.285300Z

I wonder if it's better to use a http client that returns CompletableFutures, like https://github.com/gnarroway/hato

nivekuil 2021-02-17T17:21:34.285600Z

are you getting that error from the smart map call or the p.eql/process call?

Chicão 2021-02-17T17:21:56.285800Z

at the p.eql/process call.

nivekuil 2021-02-17T17:23:45.286100Z

but the smart map call works? maybe you can't pass the psm/with-error-mode to an env used for eql calls? It's under the smart map namespace so I think it wouldn't do anything for p.eql anyway

Chicão 2021-02-17T17:25:52.286300Z

the smart-map calls works, and if I change my mutation to another resolver it'll be work too.

nivekuil 2021-02-17T17:26:48.286500Z

try making a different env, without psm/with-error-mode for the p.eql call

nivekuil 2021-02-17T17:27:02.286700Z

I don't think there's any reason for that to be part of the p.eql env

Chicão 2021-02-17T17:27:19.286900Z

I really don't know what is the problem (initial I was thing that pathon was cache the others http calls , but i really don't know hehe

Chicão 2021-02-17T17:27:49.287100Z

I remove psm/with-error-mode from env and the mutations was called

nivekuil 2021-02-17T17:31:51.287300Z

yeah so psm/with-error-mode may be incompatible with p.eql, but does work with mutations

👍 1
wilkerlucio 2021-02-17T17:37:08.287600Z

it shouldn't be, the eql runner just ignores the smart map error mode, it has no relationship

wilkerlucio 2021-02-17T17:37:32.287800Z

@matheusfrancisco001 I can't follow your line numbers on this example

wilkerlucio 2021-02-17T17:38:01.288Z

can you send a minimal reproduction of the problem? that's the best way to bring some issue

Chicão 2021-02-17T17:38:52.288200Z

i'm trying to reproduce this with a mock server http, but doesn't throw the error..

Chicão 2021-02-17T17:39:43.288400Z

I try to create a minimal example here https://gist.github.com/matheusfrancisco/09de37256dd94d8935e4d3be64adf7c9

Chicão 2021-02-17T17:45:06.288600Z

@wilkerlucio I follow the stack trace into pathom3 namespaces and in this function should have this key :com.wsscode.pathom3.attribute/attribute but it doesn't there

(defn sm-env-get
  "Get a property from a smart map.

  First it checks if the property is available in the cache-tree, if not it triggers
  the connect engine to lookup for the property. After the lookup is triggered the
  cache-tree will be updated in place, note this has a mutable effect in this data,
  but this change is consistent.

  Repeated lookups will use the cache-tree and should be as fast as reading from a
  regular Clojure map."
  ([env k] (sm-env-get env k nil))
  ([{::p.ent/keys [entity-tree*] :as env} k default-value]
   (let [ent-tree @entity-tree*]
     (if-let [x (find ent-tree k)]
       (wrap-smart-map env (val x))
       (let [ast   {:type     :root
                    :children [{:type :prop, :dispatch-key k, :key k}]}
             stats (-&gt; (pcr/run-graph! env ast entity-tree*) meta ::pcr/run-stats)]
         (when-let [error (and (refs/kw-identical? (get env ::error-mode) ::error-mode-loud)
                               (-&gt; (p.eql/process (pcrs/run-stats-env stats)
                                                  {:com.wsscode.pathom3.attribute/attribute k}
                                                  [::pcrs/attribute-error])
                                   ::pcrs/attribute-error
                                   ::pcr/node-error))]
           (throw error))
         (wrap-smart-map env (get @entity-tree* k default-value)))))))
it means something to you, that helps me to explorate this problem? in this part of code
(-&gt; (p.eql/process (pcrs/run-stats-env stats)
                                                  {:com.wsscode.pathom3.attribute/attribute k}
                                                  [::pcrs/attribute-error])
                                   ::pcrs/attribute-error
                                   ::pcr/node-error))

wilkerlucio 2021-02-17T17:56:44.289Z

@matheusfrancisco001 I just copied and ran your minimal example, but I can't see any issues

wilkerlucio 2021-02-17T17:56:56.289200Z

(p.eql/process env1  [`(mutation-ex3)])
=&gt;
#:com.wsscode.pathom3.demos.buzzlabs{mutation-ex3 #:ex.xico{:cc "<https://url2.org/post>"}}
(:ex.xico/http (psm/smart-map env1))
=&gt; "<https://httpbin.org/post>"

wilkerlucio 2021-02-17T17:58:07.289400Z

what is wrong? how can I see it in my end?

Chicão 2021-02-17T17:59:32.290Z

ys, my example doesn't throw exceptions, because I can't reproduce it my self yet. I trying to, I really don't know why this happened

eoliphant 2021-02-17T20:52:24.293400Z

Hey I’m playing around with pathom-viz (2021.2.1) via connect-env (2021.01.25), request trace is checked, and everything else looks good but traces aren’t showing up. perf meta data are on the result as expected in the repl, just don’t see the trace stufff

eoliphant 2021-02-19T22:54:12.348Z

figured it out, at a high level lol. i created a new project with just p3, worked fine. added the p2 dep, still worked fine. went back to my app, still broken. but i then removed a require in my user ns that was transitively pulling in p2 stuff, and voila! so not sure of the specifics but it’s a p2/p3 thing for sure

wilkerlucio 2021-02-19T22:58:21.348200Z

gotcha, can you make a repro case?

eoliphant 2021-02-23T17:54:22.005500Z

ok ugh, it’s happening again lol

wilkerlucio 2021-02-17T21:05:18.293800Z

using pathom 2 I guess?

wilkerlucio 2021-02-17T21:05:35.294400Z

do you have the trace plugin installed?

eoliphant 2021-02-17T21:12:48.294600Z

it’s pathom3, but i do have pathom2 jars, etc. i’m migrating the app, so just created a new ns to start playing with the v3 parser

wilkerlucio 2021-02-17T22:48:49.296Z

pathom 3 always have trace, not sure what may be going on, tried following docs from pathom viz connector?

wilkerlucio 2021-02-17T22:48:55.296400Z

or using via http?