Fork me on GitHub
#pathom
<
2020-12-04
>
genekim05:12:55

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]}]}]))

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

(go (async/<! (println x)))
(go-catch (<? x))

; TypeError: Cannot read property 'call' of undefined
;    at eval (eval at <anonymous> (), <anonymous>:1:31)

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

; TypeError: Cannot read property 'call' of undefined
;    at eval (eval at <anonymous> (), <anonymous>:1:31)
How do I get the query results? Thx! (Am I setting up the parser incorrectly? Am I using async wrong?)

wilkerlucio11:12:34

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)

wilkerlucio11:12:07

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

wilkerlucio11:12:10

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

genekim04:12:56

Thx @U066U8JQJ — 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]}}

wilkerlucio04:12:15

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

genekim04:12:30

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

genekim04:12:21

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}}

genekim04:12:12

OMG. It works!!! Thanks so much for the help, @U066U8JQJ!!!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"}]}}

🎉 3