This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-16
Channels
- # aleph (1)
- # announcements (16)
- # babashka (36)
- # beginners (62)
- # calva (15)
- # cider (21)
- # cljsrn (5)
- # clojure (84)
- # clojure-dev (3)
- # clojure-europe (22)
- # clojure-italy (2)
- # clojure-nl (2)
- # clojure-uk (3)
- # clojurescript (36)
- # core-async (2)
- # cursive (4)
- # datomic (8)
- # emacs (14)
- # events (1)
- # fulcro (4)
- # hyperfiddle (6)
- # introduce-yourself (3)
- # jobs (1)
- # leiningen (4)
- # lsp (100)
- # nrepl (3)
- # off-topic (36)
- # pathom (17)
- # podcasts-discuss (1)
- # polylith (4)
- # portal (14)
- # react (1)
- # reagent (3)
- # reitit (8)
- # releases (3)
- # remote-jobs (1)
- # reveal (7)
- # shadow-cljs (19)
- # sql (16)
- # web-security (3)
Lenient mode in Pathom3, using boundary-interface*
* and serializing to Transit: :com.wsscode.pathom3.error/node-exception
fails to serialize.
Do we need to remove that from the result before sending over the wire?
(ns pathom-boundary-interface-errors
(:require
[cognitect.transit :as transit]
[com.wsscode.pathom3.connect.operation :as pco]
[com.wsscode.pathom3.connect.indexes :as pci]
[com.wsscode.pathom3.interface.smart-map :as psm]
[com.wsscode.pathom3.interface.eql :as p.eql]
[com.wsscode.pathom3.connect.built-in.resolvers :as pbir]
[com.wsscode.pathom3.error :as p.error])
(:import
[ ByteArrayOutputStream ByteArrayInputStream]))
(def indexes
(pci/register
[(pbir/constantly-fn-resolver ::throw-error (fn [_] (throw (ex-info "Error" {}))))]))
(def pathom
(p.eql/boundary-interface
(merge
indexes
{::p.error/lenient-mode? true})))
(defn ->transit
[form]
(let [out (ByteArrayOutputStream. 4096)
writer (transit/writer out :json)]
(transit/write writer form)
(.toString out)))
; :com.wsscode.pathom3.error/exception cannot be serialized to Transit
; Throws:
; Not supported: class clojure.lang.ExceptionInfo
(->transit (pathom [::throw-error]))
what version are you using? I see something different on my end, but there is also a bug I notice
but on my end, the bug is that if you have ::p.error/lenient-mode? true
the boundary interface will return a blank output (on latest pathom)
instead of using at the env level, you can set it on the request level as well
like this:
(pathom {:pathom/eql [::throw-error]
:pathom/lenient-mode? true})
right now, sending it there works, I'm going to fix pathom in a bit
So the Right Thing to get things over the wire is to remove any :com.wsscode.pathom3.error/node-exception
from the result?
you should bump Pathom, you are using an old version
in the new versions it already does some error processing that makes it suitable to go over the wire
I'm finishing the fix to the latest, should be out today
current latest is 2022.03.07-alpha
Thank you @U066U8JQJ! We have errors flowing over the wire
@danie just released 2022.03.17-alpha
which fixed the lenient mode from env with boundary interface
Works like a charm, thank you @U066U8JQJ
@danie just released 2022.03.17-alpha
which fixed the lenient mode from env with boundary interface