making queries really traceable and queryable
This commit is contained in:
@@ -6,7 +6,9 @@
|
||||
[buddy.auth :refer [throw-unauthorized]]
|
||||
[datomic.api :as d]
|
||||
[clojure.walk :as walk]
|
||||
[clojure.tools.logging :as log]))
|
||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||
[clojure.tools.logging :as log]
|
||||
[com.brunobonacci.mulog :as mu]))
|
||||
|
||||
|
||||
(defn snake->kebab [s]
|
||||
@@ -140,3 +142,24 @@
|
||||
(conj e partial)
|
||||
(str/join " " e))]
|
||||
(not-empty query))))
|
||||
|
||||
(defn trace-query [key f]
|
||||
(fn trace [a b c]
|
||||
(mu/with-context {:query key
|
||||
:mutation (boolean (= "mutation"
|
||||
(namespace key)))}
|
||||
(mu/trace (keyword "graphql" (name key))
|
||||
[]
|
||||
(f a b c)))))
|
||||
|
||||
(defn attach-tracing-resolvers [schema m]
|
||||
(attach-resolvers schema
|
||||
(reduce
|
||||
(fn [resolvers [resolver-key resolver-fn]]
|
||||
(assoc resolvers
|
||||
resolver-key (trace-query resolver-key resolver-fn))
|
||||
)
|
||||
{}
|
||||
m))
|
||||
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user