Fork me on GitHub

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.


Thanks @U2845S9KL! That is an excellent way to resolve my issue!

👍 1

Note that expects value that describes the desired output does not describe whether the properties needed are single map or a collection


I need both.


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)


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


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

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])))

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


I am using

(defn parser [] (p.eql/boundary-interface pathom))


I am not sure about the boundary interface.


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))

  (request [:error]))


Ok, let me try it out and respond.


I get the same result as you do.


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.

🙏 1