Fork me on GitHub
#pathom
<
2021-02-17
>
Chicão16:02:01

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 "" {:headers {:Content-Type "application/json"}})})

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

(def env1 (->
            (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?

nivekuil17:02:14

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

nivekuil17:02:34

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

Chicão17:02:56

at the p.eql/process call.

nivekuil17:02:45

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ão17:02:52

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

nivekuil17:02:48

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

nivekuil17:02:02

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

Chicão17:02:19

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ão17:02:49

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

nivekuil17:02:51

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

👍 3
wilkerlucio17:02:08

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

wilkerlucio17:02:32

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

wilkerlucio17:02:01

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

Chicão17:02:52

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

Chicão17:02:06

@U066U8JQJ 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 (-> (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)
                               (-> (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
(-> (p.eql/process (pcrs/run-stats-env stats)
                                                  {:com.wsscode.pathom3.attribute/attribute k}
                                                  [::pcrs/attribute-error])
                                   ::pcrs/attribute-error
                                   ::pcr/node-error))

wilkerlucio17:02:44

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

wilkerlucio17:02:56

(p.eql/process env1  [`(mutation-ex3)])
=>
#:com.wsscode.pathom3.demos.buzzlabs{mutation-ex3 #:ex.xico{:cc ""}}
(:ex.xico/http (psm/smart-map env1))
=> ""

wilkerlucio17:02:07

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

Chicão17:02:32

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

eoliphant20:02:24

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

wilkerlucio21:02:18

using pathom 2 I guess?

wilkerlucio21:02:35

do you have the trace plugin installed?

eoliphant21:02:48

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

wilkerlucio22:02:49

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

wilkerlucio22:02:55

or using via http?

eoliphant02:02:53

Will dbl check the docs, etc

eoliphant22:02:12

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

wilkerlucio22:02:21

gotcha, can you make a repro case?

eoliphant17:02:22

ok ugh, it’s happening again lol