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]}
Thanks! I can see that being useful.
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]}])))