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 527d963..0733669 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/deliver! l-prom nil {:message (.getMessage error)})) + sl-result))) (defmacro with-superlifter [ctx body] `(api/with-superlifter (get-in ~ctx [:request :superlifter])