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> (<http://localhost:8087/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:823:8>), <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> (<http://localhost:8087/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:823:8>), <anonymous>:1:31)
How do I get the query results? Thx! (Am I setting up the parser incorrectly? Am I using async wrong?)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)
I tried it here, for some reason it fails with go
, but works with go-catch
:
(go-catch
(js/console.log
(<?
(intparser {} [{[:vimeo.user/id 118038002]
[{:vimeo.album-list/data [:vimeo.album/uri]}]}]))))
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]}}
did you changed the parser to use async-parser
too? it should return a channel from the parser call
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)
(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!)
Sorry, wrong github link: https://github.com/realgenekim/pathom-demo/blob/gene-vimeo-hacking-away/src/demo/cards/workspaces_main.cljs
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}}
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"}]}}