This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-17
Channels
- # beginners (26)
- # calva (7)
- # cider (6)
- # cljs-dev (7)
- # clojure (86)
- # clojure-europe (1)
- # clojure-finland (1)
- # clojure-spec (3)
- # clojure-uk (11)
- # clojurescript (18)
- # cursive (6)
- # data-science (1)
- # emacs (13)
- # fulcro (34)
- # juxt (8)
- # nrepl (6)
- # off-topic (11)
- # pathom (25)
- # re-frame (13)
- # reitit (11)
- # shadow-cljs (4)
- # spacemacs (3)
anyone using pathom with nodeJS?
@currentoor should work same as running in the browser, are finding issues to setup?
no just wondering if there was an example already written somewhere
shouldn’t be too hard to figure out
yeah, you can hook on web framework like express
if you go for it, remember to return promise channels on the resolvers that do async calls (like http requests)
pathom can leverage that on the coordination side 😉
sounds good
:thumbsup:
as part of our product we need on-site controllers to interact with equipment like bar code scanners and printers
so i’m writing those as node servers on small linux devices
I’m having troubled connecting pathom in-browser mutations to my fulcro application
that’s a gist of how i set it up
but when i trigger that remote mutation, like so in the Fulcro Inspect Query tab
[{(ucv.ui.receipt/print-receipt
{:remote :rest,
:order/id #uuid "4eb5af84-1611-4d79-8c3b-4acf919e1e82"})
[*]}]
but when i look at the indexes (shown in the gist) i see that this mutation is indeed in there
In the js console i see this error PathomRemote error: Error: Assert failed: Parse mutation attempted but no :mutate function supplied
@currentoor you need to provide ::p/mutate pc/mutate-async
or something like
https://wilkerlucio.github.io/pathom/#_mutations_setup
@souenzzo thanks, i did that and it works from the repl
(pc/defresolver print-receipt [{:keys [app-atom ast]} {:keys [firm order]}]
{#_#_::pc/params [:firm :order]
::pc/output [:receipt-printer/success]}
(util/spy firm order)
(go-catch
(let [controller-api ""
response (async/<! (http/post controller-api
{:body (transit-clj->str
{:firm firm :order order})
:with-credentials? false}))]
(util/spy :pp (transit-str->clj (:body response))))))
my parser now looks like this
(defn rest-parser
"Create a REST parser. Make sure you've required all nses that define rest resolvers. The given app-atom will be available
to all resolvers in `env` as `:app-atom`."
[app-atom]
(p/parallel-parser
{::p/env {::p/reader [p/map-reader
pc/parallel-reader
pc/open-ident-reader
p/env-placeholder-reader]
::p/placeholder-prefixes #{">"}}
::p/mutate pc/mutate-async
::p/plugins [(p/env-plugin {:app-atom app-atom})
(pc/connect-plugin {::pc/register (vec (vals @pathom-registry))})
p/error-handler-plugin
p/request-cache-plugin
(p/post-process-parser-plugin p/elide-not-found)]}))
and this works when i evaluate it in the repl
(comment
(go-catch
(util/spy (async/<! ((rest-parser) {}
'[(ucv.ui.receipt/print-receipt {})])))))
but for some reason triggering it from fulcro does doesn’t work
however, if i only change pc/defresolver
to pc/defmutation
then it works as expected