This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-28
Channels
- # announcements (33)
- # aws (2)
- # babashka (14)
- # beginners (128)
- # calva (34)
- # cestmeetup (3)
- # clj-kondo (12)
- # cljdoc (3)
- # clojure (114)
- # clojure-europe (31)
- # clojure-italy (3)
- # clojure-nl (7)
- # clojure-uk (6)
- # clojurescript (35)
- # conjure (20)
- # cursive (3)
- # data-science (3)
- # datomic (16)
- # docker (13)
- # events (1)
- # figwheel-main (22)
- # fulcro (109)
- # jobs (1)
- # kaocha (8)
- # keechma (1)
- # lambdaisland (5)
- # malli (1)
- # meander (8)
- # mid-cities-meetup (1)
- # off-topic (6)
- # overtone (7)
- # pathom (6)
- # re-frame (2)
- # reitit (9)
- # ring (1)
- # shadow-cljs (92)
- # specter (1)
- # tools-deps (311)
- # xtdb (76)
Is it possible to update the environment from a mutation for a subsequent mutation join?
@jackson.reynolds yes, here is an example:
(ns com.wsscode.pathom.union-repro
(:require
[clojure.core.async :as async]
[com.wsscode.pathom.core :as p]
[com.wsscode.pathom.connect :as pc]))
(pc/defresolver x [env {:keys []}]
{::pc/output [::x]
::pc/cache? false}
{::x (:x env)})
(pc/defmutation sample-call [env _]
{}
{:foo "bar"
::p/env (assoc env :x "meh")})
(def resolver-registry [sample-call x])
(def parser
(p/parser
{::p/env {::p/reader [p/map-reader
pc/reader2
pc/open-ident-reader
p/env-placeholder-reader]
::p/placeholder-prefixes #{">"}}
::p/mutate pc/mutate
::p/plugins [(pc/connect-plugin {::pc/register resolver-registry})
p/error-handler-plugin
p/trace-plugin]}))
(comment
(parser {:x "bla"}
[::x
{(list `sample-call {}) [::x]}])
; => {::x "bla"
; sample-call {::x "meh"}}
)
Thanks. That was my first inclination as well but it seems that as soon as I add ::p/env
to the return map I get a NullPointerException. I can prn
the new environment just fine and I’m not asking to see it in the EQL query. If I add the environment as ::env
instead, I don’t get an exception and obviously don’t update the environment; but as soon as I change it to ::p/env
I get the exception.
In fact, I still get {:com.wsscode.pathom.core/reader-error “class java.lang.NullPointerException”} with your example.