This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-10
Channels
- # announcements (1)
- # apache-kafka (1)
- # beginners (61)
- # bigdata (1)
- # brompton (3)
- # buddy (1)
- # calva (18)
- # clara (2)
- # clj-commons (1)
- # clj-kondo (21)
- # cljs-dev (2)
- # clojure (32)
- # clojure-europe (10)
- # clojure-filipino (4)
- # clojure-france (2)
- # clojure-italy (5)
- # clojure-nl (4)
- # clojure-spec (28)
- # clojure-uk (14)
- # clojurescript (6)
- # conjure (1)
- # cursive (5)
- # data-science (1)
- # datahike (2)
- # datomic (9)
- # emacs (4)
- # esprit (17)
- # fulcro (14)
- # jobs (1)
- # jobs-discuss (18)
- # lsp (1)
- # malli (27)
- # msfs2020 (22)
- # off-topic (7)
- # pathom (3)
- # portal (1)
- # re-frame (23)
- # reagent (4)
- # reitit (1)
- # remote-jobs (1)
- # shadow-cljs (5)
- # sql (11)
- # tools-deps (77)
- # vim (19)
can a pathom mutation utilize resolvers to load data, or can it only utilize parameters explicitly passed to it?
for example, if I pass a user/id
to the mutation, can i use my already written resolves to load other fields, or would i have to load them from explicitly from whatever data-source I’m using?
@tylernisonoff you can do
(pc/defmutation do-thing [{:keys [parser]
:as env} {:user/keys [id]}]
{::pc/params [:user/id]}
(let [eid [:user/id id]
user-with-address (-> env
(parser [{eid [:user/id
:user/address]}])
(get eid))]
...))
Yeah, I agree with you that pc
could implement something like ::pc/resolved-params
that take ::pc/params
as input and resolve it.Using ::pc/transform
(let [connect-params (fn [{::pc/keys [mutate]
::keys [connected-params]
:as mutation}]
(if connected-params
(assoc mutation
::pc/mutate (fn [{:keys [parser] :as env}
[eid & {:as others}]]
(let [result (parser env `[{(~eid ~{:pathom/context others})
~connected-params}])]
(mutate env (get result eid)))))
mutation))
parser (ps/connect-serial-parser
[(pc/mutation
`op {::pc/params [:a]
::connected-params [:a :b]
::pc/transform connect-params}
(fn [_ params] params))
(pc/resolver
`b {::pc/input #{:a} ::pc/output [:b]}
(fn [_ {:keys [a]}]
{:b (str [:b a])}))])]
(parser {} `[(op {:a 42})]))