From 17f294e36fef3006c0ee43cc458b317424b4e5b3 Mon Sep 17 00:00:00 2001 From: Gyeongmin Park Date: Thu, 22 Aug 2024 14:59:08 +0900 Subject: [PATCH] complexity errors to extensions.warnings --- src/com/walmartlabs/lacinia.clj | 18 +++++++++--------- src/com/walmartlabs/lacinia/executor.clj | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/com/walmartlabs/lacinia.clj b/src/com/walmartlabs/lacinia.clj index 6ed496f9..b5d1576f 100644 --- a/src/com/walmartlabs/lacinia.clj +++ b/src/com/walmartlabs/lacinia.clj @@ -58,17 +58,16 @@ (seq validation-errors) (resolve/resolve-as {:errors validation-errors}) - - :let [complexity-error (when (:max-complexity options) - (complexity-analysis/complexity-analysis prepared options))] - (some? complexity-error) - (resolve/resolve-as {:errors complexity-error}) + :let [complexity-error (when (:max-complexity options) + (complexity-analysis/complexity-analysis prepared options))] - :else - (executor/execute-query (assoc context constants/parsed-query-key prepared - ::tracing/validation {:start-offset start-offset - :duration (tracing/duration start-nanos)}))))) + :else (executor/execute-query (assoc context constants/parsed-query-key prepared + :warnings (if complexity-error + (atom [complexity-error]) + (atom [])) + ::tracing/validation {:start-offset start-offset + :duration (tracing/duration start-nanos)}))))) (defn execute-parsed-query "Prepares a query, by applying query variables to it, resulting in a prepared @@ -86,6 +85,7 @@ :or {timeout-ms 0 timeout-error {:message "Query execution timed out."}}} options execution-result (execute-parsed-query-async parsed-query variables context options) + _ (prn execution-result) result (do (resolve/on-deliver! execution-result *result) ;; Block on that deliver, then return the final result. diff --git a/src/com/walmartlabs/lacinia/executor.clj b/src/com/walmartlabs/lacinia/executor.clj index d7bc0c62..43341083 100644 --- a/src/com/walmartlabs/lacinia/executor.clj +++ b/src/com/walmartlabs/lacinia/executor.clj @@ -383,7 +383,7 @@ (binding [resolve/*callback-executor* executor] (let [enabled-selections (remove :disabled? selections) *errors (atom []) - *warnings (atom []) + *warnings (:warnings context) *extensions (atom {}) *resolver-tracing (when (::tracing/enabled? context) (atom []))