This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-30
Channels
- # announcements (40)
- # babashka (41)
- # beginners (32)
- # calva (15)
- # clara (8)
- # clj-kondo (14)
- # cljs-dev (30)
- # clojure (37)
- # clojure-dev (8)
- # clojure-europe (21)
- # clojure-norway (21)
- # clojure-uk (4)
- # clojured (3)
- # clojurescript (4)
- # community-development (10)
- # core-async (13)
- # cursive (23)
- # datomic (15)
- # emacs (9)
- # fulcro (3)
- # google-cloud (4)
- # graphql (24)
- # gratitude (2)
- # holy-lambda (4)
- # honeysql (5)
- # hyperfiddle (9)
- # keechma (1)
- # klipse (5)
- # lsp (23)
- # malli (4)
- # missionary (32)
- # pathom (28)
- # re-frame (2)
- # reagent (40)
- # reitit (17)
- # releases (2)
- # remote-jobs (1)
- # shadow-cljs (25)
- # specter (3)
- # vim (19)
- # xtdb (41)
I am trying to use (non-dynamic) resolvers with Datomic pull syntax. I thought it would map easily, but the problem is that if there insufficient data from the pull, then Pathom is throwing an error. I would like it to return nil or find a way to process the error. I am really stuck on this. Any help would be greatly appreciated!
Your resolver will have to merge in the nil values. You might try something like this:
(merge {:output/one nil, :output/two nil ...}
(datomic/pull ...))
If you want to be a bit more dynamic, I think there's a way for your resolver to introspect the Pathom environment to discover its output variable.
Note that expects value that describes the desired output does not describe whether the properties needed are single map or a collection
another option is to use lenient mode, which is fine with partial errors, but this choice should be made depending if you are more like "I need all or nothing" (strict mode, which is the default) or "get me whatever you can and I'll work with it" (lenient mode) https://pathom3.wsscode.com/docs/error-handling#lenient-mode
the approach of merging is fine and I also used it a bunch of times, but keep in mind that when you do that, you lose the ability to have a separate resolver for those keys from a different source, its not a bad thing nescessarily, but something to keep in mind
I don’t know how to correctly use lenient mode. The errors jam up my middleware, because I don’t process them correctly. Do you have a code snippet for error handling
lenient mode will always give a map with data, and error details for anything that failed, present at the same level (entity) that had that attr failure, the error handling here is different because you moved from "all or nothing" to partial errors, and when dealing with partial errors you have to handle errors for each attribute individually
this mode is recommended for example when doing UI's with Fulcro, given that most UI's are fine with partial data missing, but then the UI must check issues per attribute
makes sense?
Ok. I can check on the UI side (I am using re-frame). The difficulty I am having is that the errors don’t serialize properly, so my middleware crashes on it. Any suggestions for that?
are you using the latest pathom? serialization shouldn't be a problem, but if you are on latest and it is, let me know and we can dig on it
(latest is 2022.06.01-alpha
)
I am using
"2022.06.01-alpha"
I think Exceptions are not serializable. I am using muuntaja
ok, gimme a sec to check something
I just tried this demo:
(pco/defresolver error []
{:error (throw (ex-info "err" {}))})
(def env (-> {:com.wsscode.pathom3.error/lenient-mode? true}
(pci/register [error])))
(comment
(p.eql/process env [:error]))
when I look at the response, its just maps, no Exception
entry, so I wonder what is going on at your end
this is what I see here:
should yield the same result (tested here):
(pco/defresolver error []
{:error (throw (ex-info "err" {}))})
(def env (-> {:com.wsscode.pathom3.error/lenient-mode? true}
(pci/register [error])))
(def request (p.eql/boundary-interface env))
(comment
(request [:error]))
so we have to figure whats going on during your other call, can you try to log it at your case and see what is getting in the output?
It works for this simple test. There’s is something else wrong with my muuntaja setup. Thanks @U066U8JQJ for your help.