From 4cf72e6c1eeb490b59c472940b724cb9ab15b5f6 Mon Sep 17 00:00:00 2001 From: Youngil Choi Date: Tue, 9 Aug 2022 05:13:02 +0900 Subject: [PATCH 1/2] =?UTF-8?q?deliver!=20=EB=8C=80=EC=8B=A0=20resolve-as?= =?UTF-8?q?=EB=A5=BC=20=EC=8D=A8=EC=84=9C=20error=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/superlifter/lacinia.clj | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/superlifter/lacinia.clj b/src/superlifter/lacinia.clj index 527d963..9116d82 100644 --- a/src/superlifter/lacinia.clj +++ b/src/superlifter/lacinia.clj @@ -15,10 +15,11 @@ (defn ->lacinia-promise [sl-result] (let [l-prom (resolve/resolve-promise)] - (api/unwrap (fn [result] (resolve/deliver! l-prom result)) - (fn [error] (resolve/deliver! l-prom nil {:message (.getMessage error)})) - sl-result) - l-prom)) + @(api/unwrap (fn [result] + (resolve/deliver! l-prom result)) + (fn [error] + (resolve/resolve-as nil {:message (.getMessage error)})) + sl-result))) (defmacro with-superlifter [ctx body] `(api/with-superlifter (get-in ~ctx [:request :superlifter]) From b45376ace685407f49aa76c11c9d2062bfd1d84e Mon Sep 17 00:00:00 2001 From: Youngil Choi Date: Tue, 9 Aug 2022 17:22:17 +0900 Subject: [PATCH 2/2] =?UTF-8?q?prom/handle=EC=9D=84=20=EC=93=B0=EA=B2=8C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/superlifter/api.cljc | 7 ++++--- src/superlifter/lacinia.clj | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/superlifter/api.cljc b/src/superlifter/api.cljc index 1b75b4d..e3da552 100644 --- a/src/superlifter/api.cljc +++ b/src/superlifter/api.cljc @@ -8,9 +8,10 @@ ([f p] (unwrap f identity p)) ([then-f catch-f p] (if (prom/promise? p) - (-> p - (prom/then then-f) - (prom/catch catch-f)) + (prom/handle p (fn [result error] + (if error + (catch-f error) + (then-f result)))) (prom/resolved (then-f p))))) #?(:clj (defmacro def-fetcher [sym bindings do-fetch-fn] diff --git a/src/superlifter/lacinia.clj b/src/superlifter/lacinia.clj index 9116d82..0733669 100644 --- a/src/superlifter/lacinia.clj +++ b/src/superlifter/lacinia.clj @@ -18,7 +18,7 @@ @(api/unwrap (fn [result] (resolve/deliver! l-prom result)) (fn [error] - (resolve/resolve-as nil {:message (.getMessage error)})) + (resolve/deliver! l-prom nil {:message (.getMessage error)})) sl-result))) (defmacro with-superlifter [ctx body]