From bbd948878d7aa981c6955c775e97fda73cb28bdb Mon Sep 17 00:00:00 2001 From: Wilker Lucio Date: Thu, 5 Dec 2024 01:03:52 -0300 Subject: [PATCH] Remove elided value, use a function to closure around the graph on planner error --- src/main/com/wsscode/misc/elided_value.cljc | 29 ------------------- .../com/wsscode/pathom3/connect/planner.cljc | 7 +++-- 2 files changed, 5 insertions(+), 31 deletions(-) delete mode 100644 src/main/com/wsscode/misc/elided_value.cljc diff --git a/src/main/com/wsscode/misc/elided_value.cljc b/src/main/com/wsscode/misc/elided_value.cljc deleted file mode 100644 index ac49cccd..00000000 --- a/src/main/com/wsscode/misc/elided_value.cljc +++ /dev/null @@ -1,29 +0,0 @@ -(ns com.wsscode.misc.elided-value) - -(def ELIDE_TEXT "Elided value, deref to read it.") - -(deftype ElidedValue [x] - #?@(:clj [clojure.lang.IDeref - (deref [_] x)] - :cljs [IDeref - (-deref [_] x)]) - - #?@(:cljs [IPrintWithWriter - (-pr-writer [_ writer _] - (write-all writer ELIDE_TEXT))]) - - Object - (toString [_] ELIDE_TEXT)) - -#?(:clj - (do (defmethod print-method ElidedValue [_ ^java.io.Writer writer] - (print-method ELIDE_TEXT writer)) - - (defmethod print-dup ElidedValue [_ ^java.io.Writer writer] - (print-method ELIDE_TEXT writer)))) - -(defn elided-value - "Wraps a value with ElidedValue. This will affect how it prints, it will always print the same text. To get the original - value, you must deref it." - [x] - (->ElidedValue x)) diff --git a/src/main/com/wsscode/pathom3/connect/planner.cljc b/src/main/com/wsscode/pathom3/connect/planner.cljc index 800f4dd6..c90b626b 100644 --- a/src/main/com/wsscode/pathom3/connect/planner.cljc +++ b/src/main/com/wsscode/pathom3/connect/planner.cljc @@ -5,7 +5,6 @@ [clojure.string :as str] [com.fulcrologic.guardrails.core :refer [>def >defn >fdef => | <- ?]] [com.wsscode.misc.coll :as coll] - [com.wsscode.misc.elided-value :as ev] [com.wsscode.misc.refs :as refs] [com.wsscode.pathom3.attribute :as p.attr] [com.wsscode.pathom3.cache :as p.cache] @@ -35,6 +34,10 @@ "The graph container, requires nodes." (s/keys :req [::nodes])) +(>def ::graph-fn + "A function that returns a graph, used to hide the graph from long error messages" + any?) + (>def ::available-data "An shape descriptor declaring which data is already available when the planner starts." (? ::pfsd/shape-descriptor)) @@ -1710,7 +1713,7 @@ (ex-info (str "Pathom can't find a path for the following elements in the query: " (pr-str (pfsd/shape-descriptor->query missing)) (p.path/at-path-string env)) - {::graph (ev/elided-value graph) + {::graph-fn (fn [] graph) ::unreachable-paths missing ::unreachable-details (unreachable-details env graph missing) ::p.path/path (get env ::p.path/path)