Skip to content

Instantly share code, notes, and snippets.

@souenzzo

souenzzo/p3.clj Secret

Created September 24, 2021 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save souenzzo/ff7bda87108cb51adc5f7db4aa367b6e to your computer and use it in GitHub Desktop.
Save souenzzo/ff7bda87108cb51adc5f7db4aa367b6e to your computer and use it in GitHub Desktop.
(p.eql/process (-> (p.plugin/register
{::p.plugin/id `as-plugin
:com.wsscode.pathom3.format.eql/wrap-map-select-entry
(fn [original]
(fn [env out {:keys [params dispatch-key]
:as ast}]
(if-let [as (:as params)]
(original env
(into (empty out) (map (fn [[k v]]
[({dispatch-key as} k k) v]))
out)
(assoc ast :key as :dispatch-key as))
(original env out ast))))})
(pci/register (pco/resolver `a
{::pco/output [:a]
::pco/params [:v]
::pco/resolve (fn [env input]
{:a (:v (pco/params env))})}))
(assoc ::pcr/resolver-cache* nil))
`[(:a {:v 1
:as :a1})
(:a {:v 2
:as :a2})])
=> {:a1 1
:a2 1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment