Skip to content

Instantly share code, notes, and snippets.

@loliveira
Created September 30, 2021 09:54
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 loliveira/37e744c90730339c6a30e47fbab7b56c to your computer and use it in GitHub Desktop.
Save loliveira/37e744c90730339c6a30e47fbab7b56c to your computer and use it in GitHub Desktop.
Plugin alterado para incluir a entity na resolução dos parâmetros da mutation
(p.plugin/defplugin mutation-resolve-params
"Remove the run stats from the result meta. Use this in production to avoid sending
the stats. This is important for performance and security.
TODO: error story is not complete, still up to decide what to do when params can't
get fulfilled."
{::pcr/wrap-mutate
(fn mutation-resolve-params-external [mutate]
(fn mutation-resolve-params-internal [env {:keys [key] :as ast}]
(let [{::pco/keys [params]} (pci/mutation-config env key)
entity (p.ent/entity env)
entity-params (merge (:params ast) entity)]
(clet [params' (if params
(if (::pcra/async-runner? env)
(p.a.eql/process env entity-params params)
(p.eql/process env entity-params params))
(:params ast))]
(mutate env (assoc ast :params params'))))))})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment