Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .clj-kondo/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{:config-paths ["imports/better-cond/better-cond"
"imports/io.pedestal/pedestal.log"]

:linters
{;; Protocol/interface implementations routinely have unused bindings for
;; parameters they must declare but don't use.
:unused-binding {:level :off}

;; `coercion-failure` and `as-conformer` are deprecated for external use but are
;; still used internally in schema.clj for default scalar definitions, in parser.clj
;; as part of parsing, and in tests that validate backward-compatibility behaviour.
:deprecated-var {:level :off}

;; `wrap-list` and `expand-implements` are private vars that appear unused to kondo
;; but are exercised at runtime.
:unused-private-var {:exclude [com.walmartlabs.lacinia.schema/wrap-list
com.walmartlabs.lacinia.schema/expand-implements]}

;; Some functions use {:added "x.y.z"} metadata maps in their body; kondo flags
;; these as unused values. This pattern is valid in Clojure.
:unused-value {:level :off}

;; Redundant-let warnings fire inside b/cond :let blocks; suppress globally since
;; the false-positive rate is high and real redundant lets are trivially visible.
:redundant-let {:level :off}}}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ build.xml
.classpath
*.pom.asc
.cpcache
.clj-kondo/*
!.clj-kondo/config.edn
19 changes: 19 additions & 0 deletions build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

(ns build
(:require [clojure.string :as string]
[clj-commons.ansi :refer [pout]]
[clojure.tools.build.api :as build]
[net.lewisship.build :as b]))

Expand Down Expand Up @@ -69,3 +70,21 @@
(println "Pushing changes ...")
(build/process {:dir publish-dir
:command-args ["git" "push"]}))

(defn lint
"Lint source files using clj-kondo."
[opts]
(let [lint-options (merge {:lint ["src" "test"]
:config
{:linters
{:unresolved-symbol
{:exclude '[(clojure.test/is [match?])]}}}}
opts)
kondo-run! (requiring-resolve 'clj-kondo.core/run!)
kondo-print! (requiring-resolve 'clj-kondo.core/print!)
results (kondo-run! lint-options)]
(kondo-print! results)
(when (pos? (get-in results [:summary :errors] 0))
(pout [:red [:bold "ERROR"] ": clj-kondo found errors 😢"])
(System/exit -1))
(pout [:bold.green "clj-kondo approves ☺️"])))
61 changes: 33 additions & 28 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
{:deps {org.clojure/clojure {:mvn/version "1.12.5"}
org.antlr/antlr4-runtime {:mvn/version "4.13.2"}
org.flatland/ordered {:mvn/version "1.15.12"}
org.clojure/data.json {:mvn/version "2.5.2"}}
{:deps {org.clojure/clojure {:mvn/version "1.12.5"}
org.antlr/antlr4-runtime {:mvn/version "4.13.2"}
org.flatland/ordered {:mvn/version "1.15.12"}
org.clojure/data.json {:mvn/version "2.5.2"}
better-cond/better-cond {:mvn/version "2.1.5"}}
:paths ["src" "resources" "target/classes"]

:deps/prep-lib
{:ensure "target/classes"
:alias :build
:fn compile-java}
:alias :build
:fn compile-java}
:aliases
{:dev
{:extra-deps {criterium/criterium {:mvn/version "0.4.6"}
org.clojure/core.async {:mvn/version "1.9.865"}
expound/expound {:mvn/version "0.9.0"}
joda-time/joda-time {:mvn/version "2.14.2"}
com.walmartlabs/test-reporting {:mvn/version "1.2"}
io.github.hlship/trace {:mvn/version "1.4"}
io.pedestal/pedestal.log {:mvn/version "0.8.1"}
org.clojure/test.check {:mvn/version "1.1.3"}
org.clojure/data.csv {:mvn/version "1.1.1"}
org.clojure/tools.cli {:mvn/version "1.4.256"}
com.clojure-goes-fast/clj-async-profiler {:mvn/version "1.7.0"}}
:jvm-opts ["-Xmx1g"
"-Xms1g"
"-XX:NewSize=200m"
"-XX:MaxNewSize=500m"
"-XX:-OmitStackTraceInFastThrow"
"-XX:+UnlockDiagnosticVMOptions"
"-XX:+DebugNonSafepoints"
"-XX:FlightRecorderOptions=stackdepth=256"
"-Djdk.attach.allowAttachSelf"
"-Dapple.awt.UIElement=true"]
{:extra-deps {criterium/criterium {:mvn/version "0.4.6"}
org.clj-commons/pretty {:mvn/version "3.8.0"}
io.github.tonsky/clj-reload {:mvn/version "1.0.0"}
org.clojure/core.async {:mvn/version "1.9.865"}
expound/expound {:mvn/version "0.9.0"}
joda-time/joda-time {:mvn/version "2.14.2"}
com.walmartlabs/test-reporting {:mvn/version "1.2"}
io.github.hlship/trace {:mvn/version "1.4"}
io.pedestal/pedestal.log {:mvn/version "0.8.1"}
org.clojure/test.check {:mvn/version "1.1.3"}
org.clojure/data.csv {:mvn/version "1.1.1"}
org.clojure/tools.cli {:mvn/version "1.4.256"}
com.clojure-goes-fast/clj-async-profiler {:mvn/version "1.7.0"}}
:jvm-opts ["-Xmx1g"
"-Xms1g"
"-XX:NewSize=200m"
"-XX:MaxNewSize=500m"
"-XX:-OmitStackTraceInFastThrow"
"-XX:+UnlockDiagnosticVMOptions"
"-XX:+DebugNonSafepoints"
"-XX:FlightRecorderOptions=stackdepth=256"
"-Djdk.attach.allowAttachSelf"
"-Dapple.awt.UIElement=true"]
:extra-paths ["test" "dev-resources"]}

:clojure-11 {}
Expand All @@ -55,7 +58,9 @@

;; clj -T:build <command>
:build {:deps {io.github.hlship/build-tools
{:git/tag "0.12.1" :git/sha "05f3ae"}}
{:git/tag "0.12.1" :git/sha "05f3ae"}
clj-kondo/clj-kondo {:mvn/version "2026.04.15"}
org.clj-commons/pretty {:mvn/version "3.8.0"}}
:ns-default build}}
:net.lewisship.build/scm
{:license :asl}
Expand Down
28 changes: 14 additions & 14 deletions src/com/walmartlabs/lacinia.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[com.walmartlabs.lacinia.constants :as constants]
[com.walmartlabs.lacinia.executor :as executor]
[com.walmartlabs.lacinia.validator :as validator]
[com.walmartlabs.lacinia.internal-utils :refer [cond-let]]
[better-cond.core :as b]
[com.walmartlabs.lacinia.util :refer [as-error-map]]
[com.walmartlabs.lacinia.resolve :as resolve]
[com.walmartlabs.lacinia.tracing :as tracing])
Expand All @@ -37,7 +37,7 @@
{:pre [(map? parsed-query)
(or (nil? context)
(map? context))]}
(cond-let
(b/cond
:let [{:keys [::tracing/timing-start]} parsed-query
;; Validation phase encompasses preparing with query variables and actual validation.
;; It's somewhat all mixed together.
Expand All @@ -59,7 +59,7 @@
:else
(executor/execute-query (assoc context constants/parsed-query-key (assoc prepared
::tracing/validation {:start-offset start-offset
:duration (tracing/duration start-nanos)})))))
:duration (tracing/duration start-nanos)})))))

(defn execute-parsed-query
"Prepares a query, by applying query variables to it, resulting in a prepared
Expand All @@ -72,19 +72,19 @@
([parsed-query variables context]
(execute-parsed-query parsed-query variables context nil))
([parsed-query variables context options]
(let [*result (promise)
(let [*result (promise)
{:keys [timeout-ms timeout-error]
:or {timeout-ms 0
timeout-error {:message "Query execution timed out."}}} options
:or {timeout-ms 0
timeout-error {:message "Query execution timed out."}}} options
execution-result (execute-parsed-query-async parsed-query variables context)
result (do
(resolve/on-deliver! execution-result *result)
;; Block on that deliver, then return the final result.
(if (pos? timeout-ms)
(deref *result
timeout-ms
{:errors [timeout-error]})
@*result))]
result (do
(resolve/on-deliver! execution-result *result)
;; Block on that deliver, then return the final result.
(if (pos? timeout-ms)
(deref *result
timeout-ms
{:errors [timeout-error]})
@*result))]
(when (instance? Throwable result)
(throw result))

Expand Down
Loading