pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
genekim 2020-12-04T05:41:55.443300Z

Okay, I think I’m getting closer to having the big pieces stood up — I have a vimeo.video and vimeo-playlist , and some queries that run from Workspaces from inside a card. Now I’m trying to run those queries from inside my CLJS REPL, but all I get are errors…. All my code is here: https://github.com/realgenekim/pathom-demo/blob/gene-vimeo-hacking-away/src/demo/cards/workspaces_main.cljs#L59 Currently, the original demo code had a (defn parser [] (p/parallel-parser) , so it wouldn’t accept any arguments from the REPL. Copying the code, I just turned it into a def intparser [] (p/parallel-parser) . But the results from the REPL are shown below. I get the channel returned, but I can’t get the results out — `<!` results in a CLJS error.

(def x (intparser {} [{[:vimeo.user/id 118038002]
                         [{:vimeo.album-list/data [:vimeo.album/uri]}]}]))

; =&gt; #object[cljs.core.async.impl.channels.ManyToManyChannel]
;
; that worked, right?  so, how do I get the result of the query out?

(go (async/&lt;! (println x)))
(go-catch (&lt;? x))

; TypeError: Cannot read property 'call' of undefined
;    at eval (eval at &lt;anonymous&gt; (<http://localhost:8087/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:823:8>), &lt;anonymous&gt;:1:31)

(go (async/&lt;! (intparser {} [{[:vimeo.user/id 118038002]
                              [{:vimeo.album-list/data [:vimeo.album/uri]}]}]))))

; TypeError: Cannot read property 'call' of undefined
;    at eval (eval at &lt;anonymous&gt; (<http://localhost:8087/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:823:8>), &lt;anonymous&gt;:1:31)
How do I get the query results? Thx! (Am I setting up the parser incorrectly? Am I using async wrong?)

wilkerlucio 2020-12-04T11:32:34.443800Z

not sure whats wrong, but I noticed a few things: - you should not need to set ::pc/resolver-dispatch and ::pc/mutate-dispatch - I encourage you to prefer the async parser instead of the parallel one when learning, the parallel is way more complicated and given the overhead it adds only a few cases get real improvements from it (and if you change, remember to also change the parallel-reader to async-reader2)

wilkerlucio 2020-12-04T11:52:07.444Z

I tried it here, for some reason it fails with go, but works with go-catch:

wilkerlucio 2020-12-04T11:52:10.444200Z

(go-catch
    (js/console.log
      (&lt;?
        (intparser {} [{[:vimeo.user/id 118038002]
                        [{:vimeo.album-list/data [:vimeo.album/uri]}]}]))))

genekim 2020-12-05T04:04:56.444600Z

Thx @wilkerlucio — I switched from parallel reader to async-reader2, and now I get a result, but it has a channel in it. > (defn q [] > (intparser {} [{[:vimeo.user/id 118038002] > [{:vimeo.album-list/data [:vimeo.album/uri]}]}])) > > (q) > => {[:vimeo.user/id 118038002] > {:vimeo.album-list/data #object[cljs.core.async.impl.channels.ManyToManyChannel]}}

wilkerlucio 2020-12-05T04:06:15.444800Z

did you changed the parser to use async-parser too? it should return a channel from the parser call

genekim 2020-12-05T04:07:52.445100Z

Oh, gosh. I think I tried that once. Let me try that right now…. (What I had tried is here: https://github.com/realgenekim/pathom-demo/blob/36caaa257ed830d6c125c6acf603829cd18706b4/src/demo/cards/workspaces_main.cljs#L59)

genekim 2020-12-05T04:09:30.445400Z

(PS: is the reason I’m having so many problems is that I’m using an outdated basis to build upon? I chose the @pithyless repo from years ago… Perhaps there was a more appropriate sample to use? Okay, trying async-parser now! Thx for this help!)

genekim 2020-12-05T04:13:21.445900Z

Now I’m getting a reader error… Hmm…. Uncommenting out some of what I took out… > > {[:vimeo.user/id 118038002] {:vimeo.album-list/data :com.wsscode.pathom.core/reader-error}, :com.wsscode.pathom.core/errors {[[:vimeo.user/id 118038002] :vimeo.album-list/data] Cannot read property ‘cljs$core$IFn$_invoke$arity$1’ of null}}

genekim 2020-12-05T04:53:12.446100Z

OMG. It works!!! Thanks so much for the help, @wilkerlucio!!!I > {[:vimeo.user/id 118038002] {:vimeo.album-list/data [{:vimeo.album/uri “/users/118038002/albums/7670034”} > {:vimeo.album/uri “/users/118038002/albums/7668043"} > {:vimeo.album/uri “/users/118038002/albums/7657922”} > {:vimeo.album/uri “/users/118038002/albums/7657919"} > {:vimeo.album/uri “/users/118038002/albums/7425464”} > {:vimeo.album/uri “/users/118038002/albums/7299521"} > {:vimeo.album/uri “/users/118038002/albums/7273701”} > {:vimeo.album/uri “/users/118038002/albums/7266618"}]}}

🎉 1