This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-23
Channels
- # aleph (1)
- # architecture (4)
- # aws (7)
- # beginners (249)
- # boot (17)
- # calva (4)
- # cider (30)
- # cljdoc (7)
- # cljs-dev (1)
- # cljs-experience (3)
- # clojure (69)
- # clojure-dev (7)
- # clojure-europe (1)
- # clojure-italy (7)
- # clojure-japan (15)
- # clojure-spec (6)
- # clojure-uk (39)
- # clojurescript (51)
- # cursive (31)
- # data-science (4)
- # datavis (1)
- # datomic (40)
- # dirac (67)
- # duct (8)
- # editors (15)
- # emacs (9)
- # events (3)
- # figwheel-main (2)
- # fulcro (157)
- # juxt (4)
- # kaocha (11)
- # lein-figwheel (1)
- # off-topic (31)
- # pathom (18)
- # re-frame (4)
- # reagent (2)
- # reitit (16)
- # remote-jobs (1)
- # shadow-cljs (11)
- # specter (2)
- # speculative (1)
- # tools-deps (27)
- # vim (1)
- # yada (2)
Are there any examples of consuming pathom from JS?
@d4hines you say JS as browser or JS as node? it's CLJS or "raw JS"?
If you have a pathom API in /api
you can do fetch("/api" {method: "POST", body: "[:api/hello]"}).then(x => x.text()).then(console.log)
it will print "{:api/hello \"Hello\"}"
Oh, ok, I assumed transit was built in or something. That still leaves how to deal with namespaced keywords and other impedance mismatches between EDN and JSON, but that’s not unique to pathom.
you can also run pathon on client with something like
parser(ctx, edn.read_string("[:api/hello]")).then(edn => console.log(edn.to_js(edn)))
will print {api_hello: "Hello"}
There is really many ways to use pathom.
Ok, that last example pretty well solves it for me. Thanks!
I want to show the capabilities of pathom to co-workers, but they aren’t ready for Clojure yet 😀
hey all, trying to get a simple mutation up and running and my symbols generated by the defmutation
macro don’t seem to be getting resolved by the connect plugin registrar. code looks like the following:
(pc/defmutation test-mutation [env params]
{::pc/sym 'test-mutation
::pc/params [:test-tempid]
::pc/output [:test-id]}
(let [test-id (.toString (java.util.UUID/randomUUID))]
(println "IN MUTATION")
{:test-id test-id}))
(defn make-parser []
(p/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
::p/plugins [(pc/connect-plugin {::pc/register [test-mutation]})
p/error-handler-plugin
p/request-cache-plugin
p/trace-plugin]}))
and calling ((make-parser) {} `[(test-mutation {:test-tempid "12345678"})])
=> Mutation not found
figured it out. didn’t realized that adding the ::pc/sym
was adding an ns onto the mutation sym
The current namespace, right?
(i.e namespace in which test-mutation
was defined)
unfortunately when defining the mutation in the data format like so:
(def my-mutations
[{::pc/sym 'test/test-mutation
::pc/params [:test-tempid]
::pc/output [:test-id]
::pc/mutation (fn [env params]
(let [test-id (.toString (java.util.UUID/randomUUID))]
(println "IN MUTATION")
{:test-id test-id}))}])
and running a parse like:
(my-p {}
`[(test/test-mutation {:test-tempid "12345678"})])
I’m getting an error " Mutation not found - {:mutation test/test-mutation}"
seems like there’s some disconnect between the way the macro does symbol resolution for mutations and the data literal format
weird because the output of the mutation data literal looks like:
#:com.wsscode.pathom.connect{:sym test/test-mutation, :params [:test-tempid], :output [:test-id] ...}
unfortunately when defining the mutation in the data format like so:
(def my-mutations
[{::pc/sym 'test/test-mutation
::pc/params [:test-tempid]
::pc/output [:test-id]
::pc/mutation (fn [env params]
(let [test-id (.toString (java.util.UUID/randomUUID))]
(println "IN MUTATION")
{:test-id test-id}))}])
and running a parse like:
(my-p {}
`[(test/test-mutation {:test-tempid "12345678"})])
I’m getting an error "Mutation not found - {:mutation test/test-mutation}"
still having the issue mms
? I wonder if the test
might be expanding to somethign else