making queries really traceable and queryable

This commit is contained in:
2023-01-08 10:03:48 -08:00
parent 49c808bfc7
commit 06f59ae531
17 changed files with 2295 additions and 691 deletions

View File

@@ -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))
)