This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-28
Channels
- # asami (13)
- # babashka (6)
- # beginners (38)
- # calva (14)
- # cider (15)
- # circleci (13)
- # clj-kondo (4)
- # cljsrn (18)
- # clojure (164)
- # clojure-bay-area (3)
- # clojure-europe (46)
- # clojure-italy (8)
- # clojure-losangeles (3)
- # clojure-norway (3)
- # clojure-sweden (24)
- # clojure-uk (115)
- # clojurescript (79)
- # cursive (11)
- # datomic (24)
- # docker (2)
- # events (9)
- # figwheel-main (31)
- # fulcro (5)
- # honeysql (6)
- # jackdaw (7)
- # jobs (3)
- # jobs-discuss (16)
- # joker (1)
- # kaocha (6)
- # keechma (1)
- # lein-figwheel (1)
- # malli (6)
- # pathom (10)
- # podcasts-discuss (13)
- # practicalli (3)
- # react (4)
- # reagent (3)
- # reitit (8)
- # remote-jobs (3)
- # shadow-cljs (21)
- # sql (12)
- # tools-deps (20)
- # xtdb (24)
I am returning tempids from one of my mutations with pathom3 but noticed that it's not returning them. I thought that was working earlier but now I am rather confused. Is there a pathom3 equivalent of
::p/env {::pc/mutation-join-globals [:tempids]}
not yet, but that’s something I’m interested in making work
I think we need a new plugin entry for the planner to make this work
I solved a similar problem using ::pf.eql/wrap-map-select-entry
Here’s a link to the code which I think could work (unless the plugins have changed since I wrote that code) https://github.com/dehli/pathom3-plugins/blob/main/src/main/dehli/pathom3/plugins.cljc#L9-L38
that’s a valid option 👍
I was playing with one that can be more performant, by manipulating the AST before the whole process happens
(defn mutation-join-globals [globals]
{::p.plugin/id
`mutation-join-globals
::p.eql/wrap-process-ast
(fn [process]
(fn [env ast]
(process env
(update ast :children
#(mapv
(fn [{:keys [type children] :as ast}]
(if (and (= type :call)
(seq children))
(update ast :children into (map (fn [k] {:type :prop :dispatch-key k :key k})) globals)
ast))
%)))))})
(pco/defmutation foo []
{::pco/op-name 'foo}
{:value 2
:tempids {1 "meh"}})
(let [env (-> (pci/register
[foo])
(p.plugin/register (mutation-join-globals [:tempids])))]
(meta (p.eql/process env [{'(foo {:bar "baz"}) [:value]}])))
@bbss walking the code I remembered another simpler option for this:
(let [env (-> (pci/register
[foo])
(update :com.wsscode.pathom3.format.eql/map-select-include
coll/sconj :tempids))]
(p.eql/process env [{'(foo {:bar "baz"}) [:value]}]))
one thing to consider there, is that it will affect not just mutations, but any entity that has the :tempids
key@bbss walking the code I remembered another simpler option for this:
(let [env (-> (pci/register
[foo])
(update :com.wsscode.pathom3.format.eql/map-select-include
coll/sconj :tempids))]
(p.eql/process env [{'(foo {:bar "baz"}) [:value]}]))
one thing to consider there, is that it will affect not just mutations, but any entity that has the :tempids
key