How do I handle the situation when resolver either returns something or nothing? If I return nil from resolver (e.g. object requested doesn’t exist) I get an error:
Execution error (ExceptionInfo) at com.wsscode.pathom3.connect.runner/check-entity-requires! (runner.cljc:941).
Required attributes missing:Have a look at https://pathom3.wsscode.com/docs/error-handling/#lenient-mode
you can also make just that attribute optional
to keep in mind: if a resolver returns nil, its saying: I wasnt able to handle that request, so if there are other resolver options, try them while if return the attribute value as nil, eg {:foo nil}. them the resolver is saying: I know :foo is nil, dont look any further
and an unfulfilled value is an error, but a nil valued attribute isnt
Thanks for explanation
How do I mark attribute optional in output? Same as with inputs?
I saw optional inputs in docs I didn't find optional outputs
you always do it at input level
outputs are by default expected to be optional, they are possibilites
but the decision about if an attribute is required or optional always comes from the part asking for it (that may be a resolver input, or your main query)
so, in your query, you can have something like:
[:foo (pco/? :bar)], so you require foo, and would like :bar, but its ok if that cant be realized
the idea is this design is to maximize the utility of attributes, and leave requirements to be as close as possible of when they are used
Ok that’s interesting