pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
fenton 2021-05-25T17:02:07.009300Z

I'm trying to get pathom 3 to build with the latest rev but keep getting a null pointer exception when it tries to put together the classpath. The older (7 months ago) git sha:

{:paths ["src"]
 :deps
 {com.wsscode/pathom3
   {:git/url "<https://github.com/wilkerlucio/pathom3>"
    :sha "1f3ca76ead855609e0f27b30f6e8bf23b5bcfa0a"}}}
works and produces:
$ clj -X:deps tree 
org.clojure/clojure 1.10.3
  . org.clojure/spec.alpha 0.2.194
  . org.clojure/core.specs.alpha 0.2.56
com.wsscode/pathom3 <https://github.com/wilkerlucio/pathom3> 1f3ca76
  . com.fulcrologic/guardrails 0.0.12
    . com.taoensso/timbre 4.10.0
      . com.taoensso/encore 2.91.0
        X org.clojure/tools.reader 0.10.0 :superseded
        . com.taoensso/truss 1.5.0
      . io.aviso/pretty 0.1.33
    . expound/expound 0.7.2
  . com.wsscode/async 1.0.8
    . org.clojure/core.async 1.1.587
      . org.clojure/tools.analyzer.jvm 1.0.0
        . org.clojure/tools.analyzer 1.0.0
        . org.clojure/core.memoize 0.8.2
          . org.clojure/core.cache 0.8.2
            . org.clojure/data.priority-map 0.0.7
        . org.ow2.asm/asm 5.2
        . org.clojure/tools.reader 1.3.2 :newer-version
  . com.wsscode/cljc-misc <https://github.com/wilkerlucio/cljc-misc.git> 66ba288
  . edn-query-language/eql 1.0.0
    X org.clojure/spec.alpha 0.2.176 :older-version
    X org.clojure/core.specs.alpha 0.2.44 :older-version
  . potemkin/potemkin 0.4.5
    . clj-tuple/clj-tuple 0.2.2
    . riddley/riddley 0.1.12
but the latest git sha:
{:paths ["src"]
     :deps
     {com.wsscode/pathom3
       {:git/url "<https://github.com/wilkerlucio/pathom3>"
        :sha "354574f6a4fbd30e54c85fa41d5bf2eb7de59a39"}}}
doesn't work, it produces:
$ clj -X:deps tree 
    Error generating tree: 
    java.lang.NullPointerException
       at clojure.tools.deps.alpha.util.dir$canonicalize.invokeStatic(dir.clj:30)
       at clojure.tools.deps.alpha.util.dir$canonicalize.invoke(dir.clj:25)
       at clojure.tools.deps.alpha.extensions.deps$eval1134$fn__1136.invoke(deps.clj:27)
       at clojure.lang.MultiFn.invoke(MultiFn.java:244)
       at clojure.tools.deps.alpha$expand_deps$children_task__534$fn__536$fn__537.invoke(alpha.clj:403)
       at clojure.tools.deps.alpha.util.concurrent$submit_task$task__249.invoke(concurrent.clj:34)
       at clojure.lang.AFn.call(AFn.java:18)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
When I'm inside pathom3 project, all is well, it's just when I include it as a dependency this happens. Any ideas?

fenton 2021-05-25T17:03:08.010200Z

When I try to clj-jack-in with cider I get the additional warnings: (which may just be red herrings of

error in process sentinel:
nrepl-server-sentinel: Could not start nREPL server:
DEPRECATED: Libs must be qualified,
change refactor-nrepl =&gt; refactor-nrepl/refactor-nrepl 
WARNING: Specified aliases are undeclared: [:dev]
Error building classpath. 
java.lang.NullPointerException
	at clojure.tools.deps.alpha.util.dir$canonicalize.invokeStatic(dir.clj:30)
	at clojure.tools.deps.alpha.util.dir$canonicalize.invoke(dir.clj:25)
	at clojure.tools.deps.alpha.extensions.deps$eval1390$fn__1392.invoke(deps.clj:27)
	at clojure.lang.MultiFn.invoke(MultiFn.java:244)
	at clojure.tools.deps.alpha$expand_deps$children_task__790$fn__792$fn__793.invoke(alpha.clj:403)
	at clojure.tools.deps.alpha.util.concurrent$submit_task$task__505.invoke(concurrent.clj:34)
	at clojure.lang.AFn.call(AFn.java:18)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Jakub Holý 2021-05-25T18:37:11.012400Z

🙏 I discovered my understanding of Pathom 2 is lacking. I have a global resolver with ::pc/output {:teams [...]} and an empty input (and Pathom can see it, as per the screenshot) yet when I query for [:teams] I get back {:teams :com.wsscode.pathom.core/not-found} . What am I doing wrong? I expected the whole output of the resolver to be returned... .

✅ 1
Tomas Brejla 2021-05-26T08:40:29.019400Z

I bumped into the same problem in the past as well. I wonder what's the expected contract here. Should you always provide all those keys "promised in pc/output" in output map and therefore return at least :teams [] in case no teams actually exist in your db? If so, perhaps some sort of key-presence validation (or clj-kondo rule?) could be added to avoid mistakes like the mentioned one?

Jakub Holý 2021-05-25T18:40:01.012800Z

solved, the output lacked the [...] : ::pc/output [ {:teams [...]} ] .

👍 2
Jakub Holý 2021-05-25T18:53:15.015800Z

Another question: I am getting ::pc/reader-error with the message ":address/id is not ISeqable" when I query for a person's :address . The global resolver returns data containing: ... :address [:address/id 1] and I expect it to follow up with the other, ident resolver to get the actual data. Instead, I get the error above. Why?

✅ 1
Jakub Holý 2021-05-25T18:53:41.015900Z

These are all my resolvers:

(defresolver my-very-awesome-teams [_ _] ; a global resolver
      {::pc/input  #{}
       ::pc/output [{:teams [:team/id :team/name
                             {:team/players [:player/id :player/name :player/address]}]}]}
      {:teams [#:team{:name "Hikers" :id :hikers
                      :players [#:player{:id 1 :name "Luna" :address [:address/id 1]}
                                #:player{:id 2 :name "Sol" :address [:address/id 2]}]}]})

    (defresolver address [_ {id :address/id :as in}] ; an ident resolver
      {::pc/input #{:address/id}
       ::pc/output [:address/id :address/city]}
      (println "RES address" in)
      (case id
        1 #:address{:id 1 :city "Oslo"}
        2 #:address{:id 2 :city "Trondheim"}))

Jakub Holý 2021-05-25T18:56:07.016100Z

The ident resolver works, as [{[:address/id 1] [:address/city]}] is correctly parsed into {[:address/id 1] {:address/city "Oslo"}} .

Jakub Holý 2021-05-25T19:00:33.016300Z

If I change the data so that a player has a list of addresses instead of a single one (=> :address [[:address/id 1]]) then it works. But surely I should be able to have to-one references? What am I misunderstanding or doing wrong?

Jakub Holý 2021-05-25T19:06:20.016700Z

Solved it, I was mixing up Fulcro ident's and Pathom's idea of identity. The correct value was :address {:address/id 1} , i.e. an entity with just the ID.

wilkerlucio 2021-05-25T19:47:16.017300Z

hello @fenton, I just tried to reproduce, but running on latest pathom sha I get the correct tree output

wilkerlucio 2021-05-25T19:47:39.017500Z

any chance some other dep may be conflicting? can you try in a bare project (just clojrue and pathom as deps) and see the error remains?

wilkerlucio 2021-05-25T19:48:50.017700Z

just seeing your messages now, glad you got it figured out 🙂

👍 1
2021-05-25T20:59:41.018300Z

I'm still new to Pathom. I'd like to use my resolvers to fill in the missing values of an entity I already have and wasn't able to figure it out from the docs. Something like this:

(def data
  {:first "Alyssa"
   :last "Hacker"
   :friends [{:first "Ben"
              :last "Bitdiddle"}
             {:first "Louis"
              :last "Reasoner"}]})
(parser {} [:first :full {:friends [:first :full]}])
=&gt; {:first "Alyssa"
    :full "Alyssa Hacker"
    :friends [{:first "Ben"
               :full "Ben Bitdiddle"}
              {:first "Louis"
               :full "Louis Reasoner"}]}
I think I can skip the ident lookup by omitting pc/open-ident-reader, but how do I pass in the initial data? Also, a more general question, is this still a reasonable use of pathom?

wilkerlucio 2021-05-25T21:01:30.018500Z

hello, welcome 🙂 to pass the data directly you can use:

(parser {::p/entity (atom DATA)} [:first :full ...]}

2021-05-25T21:11:02.018800Z

Indeed--that works beautifully! Thank you!

👍 1