Last active
September 30, 2021 11:37
-
-
Save loliveira/5c907135b5a40be747aeb527666b7b7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(p.plugin/defplugin mutation-resolve-params-with-entity | |
"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 entity (:params ast))] | |
(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
a suggestion: I think params should have higher precedence than inputs (since they are closest to the mutation, the last point), so changing
(merge (:params ast) entity)
to(merge entity (:params ast))
might be better