This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-06-03
Channels
- # announcements (1)
- # asami (13)
- # babashka (14)
- # beginners (58)
- # calva (49)
- # cljs-dev (6)
- # clojure (99)
- # clojure-europe (28)
- # clojure-gamedev (4)
- # clojure-nl (19)
- # clojure-spec (4)
- # clojure-uk (39)
- # clojured (5)
- # clojurescript (39)
- # code-reviews (3)
- # conjure (4)
- # cryogen (12)
- # cursive (21)
- # data-science (4)
- # datalog (1)
- # datomic (16)
- # duct (4)
- # events (1)
- # fulcro (6)
- # graalvm (1)
- # graphql (1)
- # jobs (13)
- # jobs-discuss (23)
- # kaocha (2)
- # lsp (15)
- # malli (24)
- # missionary (6)
- # off-topic (21)
- # polylith (75)
- # releases (2)
- # remote-jobs (4)
- # shadow-cljs (47)
- # sql (35)
- # vim (10)
- # xtdb (4)
hi everyone, I'd like to clarify current state of custom directives support https://lacinia.readthedocs.io/en/latest/directives.html so code like this could work after upcoming changes
(defn- apply-directive [{:keys [directive-type directive-args] :as directive} value]
(cond-> value
(and value (= :mathInc directive-type)) (+ (:amount directive-args))))
(defn- directives-handler [field _]
(let [{:keys [directives resolve]} field]
(fn [ctx args entity]
(let [value (when resolve (resolve ctx args entity))
new-value (reduce (fn [value directive]
(apply-directive directive value))
value
directives)]
new-value))))
(schema/compile {:enable-introspection? (boolean enable-introspection?)
:apply-field-directives directives-handler})
;; in schema
{:directive-defs
{:mathInc
{:locations #{:field-definition}
:args {:amount {:type (non-null Long)}}}}
...
:someType
{:fields {:price {:type Money
:directives [{:directive-type :mathInc
:directive-args {:amount 1}}]
:resolve :product/price}}}}