This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-16
Channels
- # announcements (33)
- # atom-editor (1)
- # aws (21)
- # babashka (174)
- # babashka-sci-dev (2)
- # beginners (59)
- # calva (4)
- # chlorine-clover (9)
- # clj-kondo (51)
- # clojars (7)
- # clojure (86)
- # clojure-czech (4)
- # clojure-europe (21)
- # clojure-france (6)
- # clojure-nl (1)
- # clojure-uk (2)
- # conjure (7)
- # core-async (3)
- # core-logic (3)
- # cursive (10)
- # data-science (8)
- # datalevin (14)
- # datomic (12)
- # events (1)
- # fulcro (5)
- # graalvm (10)
- # gratitude (3)
- # honeysql (3)
- # hyperfiddle (3)
- # introduce-yourself (4)
- # joyride (3)
- # leiningen (3)
- # malli (13)
- # minecraft (15)
- # music (1)
- # off-topic (40)
- # pathom (16)
- # polylith (28)
- # portal (25)
- # rdf (15)
- # remote-jobs (3)
- # shadow-cljs (23)
- # specter (1)
- # sql (5)
- # tools-deps (25)
- # xtdb (31)
Hi all,
Currently I’m working with entity missing exceptions for our domain model. Theoretically, it’s pretty simple to add :entity/accessible?
keys to each of our xxx-by-id
resolvers, but it’d be nice to instead extend the ::pathom-runner/attribute-error
map. The intended data shape was
{:xxx/id ... ;; Entity map
::pathom-runner/attribute-error {:xxx/id :unreachable}}
However, no plugin in pathom allows extending attribute-error in this way, except for the root run node plugins as far as I can tell. Is this data shape possible with plugins? Neither ::pathom-runner/wrap-resolver-error
nor ::pathom-error/wrap-attribute-error
are capable of making this shape.so you wanna change the format of the error, let me take a look to see if I can stop some other extension point, otherwise we may add one more
I see the only place that attaches those errors in is this fn: https://github.com/wilkerlucio/pathom3/blob/db656982f186cedc434786be05c0c28229b85056/src/main/com/wsscode/pathom3/error.cljc#L96
just by looking at the code seems like ::wrap-attribute-error
should be able to update that, no? I can give a try here to double check
I have an example here, please let me know if its sufficient:
(ns com.wsscode.pathom3.demos.attribute-error-wrap
(:require [com.wsscode.pathom3.connect.operation :as pco]
[com.wsscode.pathom3.connect.indexes :as pci]
[com.wsscode.pathom3.interface.eql :as p.eql]
[com.wsscode.pathom3.plugin :as p.plugin]))
(pco/defresolver error [{::keys []}]
{:foo (throw (ex-info "lala" {}))})
(def env
(-> {:com.wsscode.pathom3.error/lenient-mode? true}
(pci/register error)
(p.plugin/register
{::p.plugin/id 'error-thing
:com.wsscode.pathom3.error/wrap-attribute-error
(fn [attr-error]
(fn [entity k]
(let [err (attr-error entity k)]
(:com.wsscode.pathom3.error/cause err))))})))
(comment
(p.eql/process env [:foo]))
result:
=>
{:com.wsscode.pathom3.connect.runner/attribute-errors {:foo :com.wsscode.pathom3.error/node-errors}}
taking a second read I see I may have misinterpreted the issue. is correct that what you want is to affect the error on the parent level according to some definition inside :xxx/id
?
So, it’s a bit more complicated unfortunately. I’d like to use an ident join to perform root loads in fulcro, but if the entity is missing return in the error key :unreachable
{[:xxx/id ...]
{:xxx/id ... ;; Entity map
::pathom-runner/attribute-error {:xxx/id :unreachable}}}
But, since :xxx/id is not being resolved by the planner, it’s not an option for the wrap-attribute-error
plugin.looking at pathomviz useage docs I think there’s a step missing.. I think you need to expose parser via an endpoint that uses Transit, am I right?
depends, if you wanna use the HTTP connection yes, but otherwise you should use the pathom viz connector: https://github.com/wilkerlucio/pathom-viz-connector/
its recommended to use the connector during dev, the http is more targeted for staging/prod environments
it runs now, but I’d love to fix #object[Object [TaggedValue: unknown, #clj-time/date-time “2020-02-13T10:20:14.000Z”]],
this is the same issue with Fulcro Inspect, because they run their own environment it would have to know about specific libraries like clj-time to handle that
so it uses the generic TaggedValue for custom types
and to everyone here, sorry I'm a bit slow these weeks, I'm on vacation and trying to stay away from computer a bit, I'll be fully back by June 27 🙂