Fork me on GitHub

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


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/id 'error-thing
         (fn [attr-error]
           (fn [entity k]
             (let [err (attr-error entity k)]
               (:com.wsscode.pathom3.error/cause err))))})))

  (p.eql/process env [:foo]))



{: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:


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 🙂

🍻 3
hammock 1
🍷 1