making queries really traceable and queryable
This commit is contained in:
2808
package-lock.json
generated
2808
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -23,8 +23,8 @@
|
||||
"recharts": "^1.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"webpack": "^5.11.0",
|
||||
"webpack-cli": "^4.2.0"
|
||||
"webpack": "^5.75.0",
|
||||
"webpack-cli": "^5.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
[postgresql/postgresql "9.3-1102.jdbc41"]
|
||||
[org.clojure/java.jdbc "0.7.11"]
|
||||
[etaoin "0.4.1"]
|
||||
[com.bhauman/figwheel-main "0.2.12" :exclusions [org.clojure/clojurescript
|
||||
[com.bhauman/figwheel-main "0.2.18" :exclusions [org.clojure/clojurescript
|
||||
ring
|
||||
ring/ring-core
|
||||
ring/ring-codec
|
||||
@@ -153,7 +153,7 @@
|
||||
|
||||
:uberjar
|
||||
{:prep-tasks ["fig:min" ]
|
||||
:dependencies [[com.bhauman/figwheel-main "0.2.12" :exclusions [org.clojure/clojurescript
|
||||
:dependencies [[com.bhauman/figwheel-main "0.2.18" :exclusions [org.clojure/clojurescript
|
||||
ring
|
||||
ring/ring-core
|
||||
ring/ring-codec
|
||||
|
||||
@@ -18,26 +18,25 @@
|
||||
[auto-ap.graphql.transaction-rules :as gq-transaction-rules]
|
||||
[auto-ap.graphql.transactions :as gq-transactions]
|
||||
[auto-ap.graphql.users :as gq-users]
|
||||
[auto-ap.graphql.utils :refer [assert-admin]]
|
||||
[auto-ap.graphql.utils :refer [assert-admin attach-tracing-resolvers]]
|
||||
[auto-ap.graphql.vendors :as gq-vendors]
|
||||
[auto-ap.graphql.yodlee-merchants :as ym]
|
||||
[auto-ap.graphql.yodlee2 :as gq-yodlee2]
|
||||
[auto-ap.logging :refer [error-event info-event warn-event] :as alog]
|
||||
[auto-ap.logging :as alog :refer [error-event info-event warn-event]]
|
||||
[auto-ap.time :as time]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clj-time.core :as t]
|
||||
[clojure.string :as str]
|
||||
[clojure.tools.logging :as log]
|
||||
[clojure.walk :as walk]
|
||||
[com.brunobonacci.mulog :as mu]
|
||||
[com.unbounce.dogstatsd.core :as statsd]
|
||||
[com.walmartlabs.lacinia :refer [execute]]
|
||||
[com.walmartlabs.lacinia.parser :as p]
|
||||
[com.walmartlabs.lacinia.schema :as schema]
|
||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||
[datomic.api :as d]
|
||||
[unilog.context :as lc]
|
||||
[yang.time :refer [time-it]]
|
||||
[com.brunobonacci.mulog :as mu])
|
||||
[yang.time :refer [time-it]])
|
||||
(:import
|
||||
(clojure.lang IPersistentMap)))
|
||||
|
||||
@@ -762,31 +761,32 @@
|
||||
|
||||
(def schema
|
||||
(-> integreat-schema
|
||||
(attach-resolvers {
|
||||
:get-yodlee-provider-account-page gq-yodlee2/get-yodlee-provider-account-page
|
||||
:get-accounts gq-accounts/get-graphql
|
||||
:get-all-accounts gq-accounts/get-all-graphql
|
||||
:get-transaction-rule-page gq-transaction-rules/get-transaction-rule-page
|
||||
:get-transaction-rule-matches gq-transaction-rules/get-transaction-rule-matches
|
||||
:get-expense-account-stats get-expense-account-stats
|
||||
:get-invoice-stats get-invoice-stats
|
||||
:get-cash-flow get-cash-flow
|
||||
:get-yodlee-merchants ym/get-yodlee-merchants
|
||||
:get-intuit-bank-accounts gq-intuit-bank-accounts/get-intuit-bank-accounts
|
||||
:vendor-by-id gq-vendors/get-by-id
|
||||
:account-for-vendor gq-accounts/default-for-vendor
|
||||
:get-user get-user
|
||||
:mutation/delete-transaction-rule gq-transaction-rules/delete-transaction-rule
|
||||
:mutation/edit-user gq-users/edit-user
|
||||
:mutation/upsert-transaction-rule gq-transaction-rules/upsert-transaction-rule
|
||||
:test-transaction-rule gq-transaction-rules/test-transaction-rule
|
||||
:run-transaction-rule gq-transaction-rules/run-transaction-rule
|
||||
:mutation/upsert-vendor gq-vendors/upsert-vendor
|
||||
:mutation/upsert-account gq-accounts/upsert-account
|
||||
:mutation/merge-vendors gq-vendors/merge-vendors
|
||||
:get-vendor gq-vendors/get-graphql
|
||||
:search-vendor gq-vendors/search
|
||||
:search-account gq-accounts/search})
|
||||
(attach-tracing-resolvers
|
||||
{
|
||||
:get-yodlee-provider-account-page gq-yodlee2/get-yodlee-provider-account-page
|
||||
:get-accounts gq-accounts/get-graphql
|
||||
:get-all-accounts gq-accounts/get-all-graphql
|
||||
:get-transaction-rule-page gq-transaction-rules/get-transaction-rule-page
|
||||
:get-transaction-rule-matches gq-transaction-rules/get-transaction-rule-matches
|
||||
:get-expense-account-stats get-expense-account-stats
|
||||
:get-invoice-stats get-invoice-stats
|
||||
:get-cash-flow get-cash-flow
|
||||
:get-yodlee-merchants ym/get-yodlee-merchants
|
||||
:get-intuit-bank-accounts gq-intuit-bank-accounts/get-intuit-bank-accounts
|
||||
:vendor-by-id gq-vendors/get-by-id
|
||||
:account-for-vendor gq-accounts/default-for-vendor
|
||||
:get-user get-user
|
||||
:mutation/delete-transaction-rule gq-transaction-rules/delete-transaction-rule
|
||||
:mutation/edit-user gq-users/edit-user
|
||||
:mutation/upsert-transaction-rule gq-transaction-rules/upsert-transaction-rule
|
||||
:test-transaction-rule gq-transaction-rules/test-transaction-rule
|
||||
:run-transaction-rule gq-transaction-rules/run-transaction-rule
|
||||
:mutation/upsert-vendor gq-vendors/upsert-vendor
|
||||
:mutation/upsert-account gq-accounts/upsert-account
|
||||
:mutation/merge-vendors gq-vendors/merge-vendors
|
||||
:get-vendor gq-vendors/get-graphql
|
||||
:search-vendor gq-vendors/search
|
||||
:search-account gq-accounts/search})
|
||||
gq-checks/attach
|
||||
gq-ledger/attach
|
||||
gq-reports/attach
|
||||
@@ -835,7 +835,7 @@
|
||||
([id q v]
|
||||
(statsd/increment "query.graphql.count" {:tags #{(str "query:" (query-name q))}})
|
||||
(statsd/time! [(str "query.graphql.time" ) {:tags #{(str "query:" (query-name q))}}]
|
||||
(mu/with-context {:query q}
|
||||
(mu/with-context {:query q :user id}
|
||||
(mu/trace
|
||||
::user-query
|
||||
[]
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
[auto-ap.graphql.utils
|
||||
:refer [->graphql
|
||||
<-graphql
|
||||
attach-tracing-resolvers
|
||||
assert-admin
|
||||
assert-can-see-client
|
||||
assert-failure
|
||||
@@ -767,4 +768,4 @@
|
||||
:mutations mutations
|
||||
:input-objects input-objects
|
||||
:enums enums})
|
||||
(attach-resolvers resolvers)))
|
||||
(attach-tracing-resolvers resolvers)))
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
[clojure.tools.logging :as log]
|
||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||
[datomic.api :as d]
|
||||
[unilog.context :as lc])
|
||||
[unilog.context :as lc]
|
||||
[auto-ap.graphql.utils :refer [attach-tracing-resolvers]])
|
||||
(:import
|
||||
(java.util UUID)
|
||||
(org.apache.commons.codec.binary Base64)))
|
||||
@@ -618,4 +619,4 @@
|
||||
:mutations mutations
|
||||
:input-objects input-objects
|
||||
:enums enums})
|
||||
(attach-resolvers resolvers)))
|
||||
(attach-tracing-resolvers resolvers)))
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
[auto-ap.datomic.expected-deposit :as d-expected-deposit]
|
||||
[auto-ap.graphql.utils
|
||||
:refer [->graphql <-graphql assert-admin ident->enum-f result->page]]
|
||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]))
|
||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||
[auto-ap.graphql.utils :refer [attach-tracing-resolvers]]))
|
||||
|
||||
(def status->graphql (ident->enum-f :expected-deposit/status))
|
||||
|
||||
@@ -72,4 +73,4 @@
|
||||
{:objects objects
|
||||
:queries queries
|
||||
:enums enums})
|
||||
(attach-resolvers resolvers)))
|
||||
(attach-tracing-resolvers resolvers)))
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
[auto-ap.graphql.utils :refer [assert-admin cleanse-query]]
|
||||
[auto-ap.graphql.vendors :refer [partial-match-first]]
|
||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||
[datomic.api :as d]))
|
||||
[datomic.api :as d]
|
||||
[auto-ap.graphql.utils :refer [attach-tracing-resolvers]]))
|
||||
|
||||
(defn search [context args _]
|
||||
(assert-admin (:id context))
|
||||
@@ -43,4 +44,4 @@
|
||||
{:objects objects
|
||||
:queries queries
|
||||
:enums enums})
|
||||
(attach-resolvers resolvers)))
|
||||
(attach-tracing-resolvers resolvers)))
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
(ns auto-ap.graphql.import-batch
|
||||
(:require
|
||||
[auto-ap.datomic
|
||||
:refer
|
||||
[add-sorter-fields apply-pagination apply-sort-3 conn merge-query]]
|
||||
:refer
|
||||
[add-sorter-fields apply-pagination apply-sort-3 conn merge-query]]
|
||||
[auto-ap.graphql.utils
|
||||
:refer
|
||||
[<-graphql assert-admin ident->enum-f result->page]]
|
||||
:refer
|
||||
[<-graphql assert-admin ident->enum-f result->page]]
|
||||
[clj-time.coerce :as coerce]
|
||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||
[datomic.api :as d]))
|
||||
[datomic.api :as d]
|
||||
[auto-ap.graphql.utils :refer [attach-tracing-resolvers]]))
|
||||
|
||||
(def default-read '[:db/id
|
||||
:import-batch/external-id
|
||||
@@ -97,4 +98,4 @@
|
||||
{:enum-value :yodlee2}
|
||||
{:enum-value :plaid}
|
||||
{:enum-value :manual}]}}})
|
||||
(attach-resolvers {:get-import-batch-page get-import-batch-page})))
|
||||
(attach-tracing-resolvers {:get-import-batch-page get-import-batch-page})))
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
(ns auto-ap.graphql.invoices
|
||||
(:require
|
||||
[auto-ap.datomic
|
||||
:refer [conn remove-nils uri]]
|
||||
[auto-ap.ledger :refer [transact-with-ledger transact-batch-with-ledger]]
|
||||
[auto-ap.datomic :refer [conn remove-nils uri]]
|
||||
[auto-ap.datomic.clients :as d-clients]
|
||||
[auto-ap.datomic.invoices :as d-invoices]
|
||||
[auto-ap.datomic.vendors :as d-vendors]
|
||||
[auto-ap.rule-matching :as rm]
|
||||
[auto-ap.graphql.checks :as gq-checks]
|
||||
[auto-ap.graphql.utils
|
||||
:as u
|
||||
:refer [<-graphql
|
||||
assert-admin
|
||||
assert-not-locked
|
||||
assert-can-see-client
|
||||
assert-power-user
|
||||
assert-failure
|
||||
assert-not-locked
|
||||
assert-power-user
|
||||
attach-tracing-resolvers
|
||||
enum->keyword]]
|
||||
[auto-ap.ledger
|
||||
:refer [transact-batch-with-ledger transact-with-ledger]]
|
||||
[auto-ap.rule-matching :as rm]
|
||||
[auto-ap.utils :refer [dollars=]]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clj-time.core :as time]
|
||||
[clojure.set :as set]
|
||||
[clojure.tools.logging :as log]
|
||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||
[datomic.api :as d]))
|
||||
|
||||
(defn ->graphql [invoice user ]
|
||||
@@ -609,4 +609,4 @@
|
||||
:mutations mutations
|
||||
:input-objects input-objects
|
||||
:enums enums})
|
||||
(attach-resolvers resolvers)))
|
||||
(attach-tracing-resolvers resolvers)))
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
[config.core :refer [env]]
|
||||
[clojure.tools.logging :as log]
|
||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||
[clojure.edn :as edn])
|
||||
[clojure.edn :as edn]
|
||||
[auto-ap.graphql.utils :refer [attach-tracing-resolvers]])
|
||||
(:import
|
||||
(com.amazonaws.services.ecs.model AssignPublicIp)))
|
||||
|
||||
@@ -156,5 +157,5 @@
|
||||
:queries queries
|
||||
:enums enums
|
||||
:mutations mutations})
|
||||
(attach-resolvers resolvers)))
|
||||
(attach-tracing-resolvers resolvers)))
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
[datomic.api :as d]
|
||||
[mount.core :as mount]
|
||||
[unilog.context :as lc]
|
||||
[yang.scheduler :as scheduler])
|
||||
[yang.scheduler :as scheduler]
|
||||
[auto-ap.graphql.utils :refer [attach-tracing-resolvers]])
|
||||
(:import [org.apache.commons.codec.binary Base64]))
|
||||
|
||||
(mount/defstate running-balance-cache
|
||||
@@ -874,4 +875,4 @@
|
||||
:mutations mutations
|
||||
:input-objects input-objects
|
||||
:enums enums})
|
||||
(attach-resolvers resolvers)))
|
||||
(attach-tracing-resolvers resolvers)))
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
assert-admin
|
||||
assert-can-see-client
|
||||
assert-present
|
||||
attach-tracing-resolvers
|
||||
limited-clients]]
|
||||
[auto-ap.plaid.core :as p]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clj-time.core :as time]
|
||||
[clojure.tools.logging :as log]
|
||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||
[datomic.api :as d]))
|
||||
|
||||
(defn plaid-link-token [context value _]
|
||||
@@ -166,8 +166,8 @@
|
||||
:delete_plaid_item {:type :message
|
||||
:args {:id {:type :id}}
|
||||
:resolve :mutation/delete-plaid-item}}})
|
||||
(attach-resolvers {:plaid-link-token plaid-link-token
|
||||
:get-plaid-item-page get-plaid-item-page
|
||||
:mutation/link-plaid link-plaid
|
||||
:mutation/delete-plaid-item delete-plaid-item})))
|
||||
(attach-tracing-resolvers {:plaid-link-token plaid-link-token
|
||||
:get-plaid-item-page get-plaid-item-page
|
||||
:mutation/link-plaid link-plaid
|
||||
:mutation/delete-plaid-item delete-plaid-item})))
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
[amazonica.aws.s3 :as s3]
|
||||
[auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.datomic.reports :as r]
|
||||
[auto-ap.graphql.utils :refer [<-graphql assert-admin result->page]]
|
||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||
[auto-ap.graphql.utils
|
||||
:refer [<-graphql assert-admin attach-tracing-resolvers result->page]]
|
||||
[config.core :refer [env]]
|
||||
[datomic.api :as d]))
|
||||
|
||||
@@ -79,4 +79,4 @@
|
||||
:mutations mutations
|
||||
:input-objects input-objects
|
||||
:enums enums})
|
||||
(attach-resolvers resolvers)))
|
||||
(attach-tracing-resolvers resolvers)))
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
(ns auto-ap.graphql.sales-orders
|
||||
(:require [auto-ap.datomic.sales-orders :as d-sales-orders2]
|
||||
[auto-ap.graphql.utils :refer [->graphql <-graphql result->page assert-admin] ]
|
||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]))
|
||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||
[auto-ap.graphql.utils :refer [attach-tracing-resolvers]]))
|
||||
|
||||
(defn get-sales-orders-page [context args _]
|
||||
(let [args (assoc args :id (:id context))
|
||||
@@ -102,4 +103,4 @@
|
||||
:mutations mutations
|
||||
:input-objects input-objects
|
||||
:enums enums})
|
||||
(attach-resolvers resolvers)))
|
||||
(attach-tracing-resolvers resolvers)))
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
[clojure.string :as str]
|
||||
[clojure.tools.logging :as log]
|
||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||
[datomic.api :as d]))
|
||||
[datomic.api :as d]
|
||||
[auto-ap.graphql.utils :refer [attach-tracing-resolvers]]))
|
||||
|
||||
(def approval-status->graphql (ident->enum-f :transaction/approval-status))
|
||||
|
||||
@@ -705,4 +706,4 @@
|
||||
:mutations mutations
|
||||
:input-objects input-objects
|
||||
:enums enums})
|
||||
(attach-resolvers resolvers)))
|
||||
(attach-tracing-resolvers resolvers)))
|
||||
|
||||
@@ -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