This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-04
Channels
- # announcements (28)
- # asami (12)
- # aws (3)
- # babashka (69)
- # babashka-sci-dev (34)
- # beginners (52)
- # biff (3)
- # calva (20)
- # clj-kondo (4)
- # cljsrn (4)
- # clojars (1)
- # clojure (90)
- # clojure-czech (2)
- # clojure-europe (33)
- # clojure-nl (11)
- # clojure-norway (35)
- # clojure-seattle (1)
- # clojure-uk (5)
- # clojurescript (87)
- # cursive (10)
- # datascript (5)
- # datomic (35)
- # defnpodcast (1)
- # emacs (8)
- # events (4)
- # fulcro (1)
- # google-cloud (2)
- # graphql (2)
- # hispano (2)
- # honeysql (5)
- # hoplon (2)
- # hugsql (1)
- # jobs (7)
- # kaocha (9)
- # lsp (102)
- # meander (13)
- # observability (7)
- # off-topic (56)
- # overtone (2)
- # pathom (47)
- # podcasts-discuss (1)
- # rdf (30)
- # reagent (16)
- # reitit (1)
- # releases (2)
- # remote-jobs (26)
- # rewrite-clj (10)
- # tools-deps (4)
- # vim (5)
- # vscode (4)
- # xtdb (41)
the most boring thing about lacinia is mapping resolvers, I always forget something. Is there any way to map it automatic using somekind of metadata stuff? Like (defn ^{:resolver :query/something} something ...)
?
I solved it with anything named *.resolver.*
like:
(defn ^{:resolver :query/todas_empresas} todas-empresas []
(fn [_ _ _]
"OK"))
with
{:queries
{:todas_empresas
{:type :String
:resolve :query/todas_empresas}}}
(defn filter-resolver [functions]
(->>
(filter
(fn [v] (contains? (meta v) :resolver))
(vals (ns-publics functions)))
(reduce #(conj %1 {(-> (meta %2) :resolver) (%2)}) {})))
(defn get-all-resovers []
(->>
(all-ns)
(map ns-name)
(filter #(.contains (name %) "resolvers"))
(reduce #(conj %1 (filter-resolver %2)) {})))
(defn- configurar-schema [arquivo-esquema]
(-> (io/resource arquivo-esquema)
slurp
edn/read-string
(util/attach-resolvers (get-all-resovers))
schema/compile))