Skip to content

Instantly share code, notes, and snippets.

@loliveira
loliveira / campos dependentes.clj
Last active November 18, 2021 06:47
Em um mapa, se tenho presente um campo ::a, quero tornar obrigatório o campo ::b e ::c também obrigatórios?
(defn multi-answer [answer]
(cond
(or (contains? answer :answer/lat)
(contains? answer :answer/lon)) :answer.type/text-with-location
:else :answer.type/text))
(defmulti data-type multi-answer)
(s/def :answer/text (and string? #(<= (count %) 4096)))
(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)
@loliveira
loliveira / resolve-mutation
Created September 30, 2021 09:54
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}]
{:user {:dependencies [[org.clojure/tools.namespace "0.2.3"]
[spyscope "0.1.3"]
[criterium "0.4.1"]]
:injections [(require '(clojure.tools.namespace repl find))
; try/catch to workaround an issue where `lein repl` outside a project dir
; will not load reader literal definitions correctly:
(try (require 'spyscope.core)
(catch RuntimeException e))]
:plugins [[lein-pprint "1.1.1"]
[lein-beanstalk "0.2.6"]