Fork me on GitHub
#pathom
<
2021-06-17
>
lsenjov21:06:07

Pathom 2.3.1. Is there a way to return nil in a field in a resolver instead of ::p/not-found? My google-fu is failing me

wilkerlucio21:06:33

there is a plugin that can help you there:

(def parser
  (p/parser {::p/plugins [;; add this one at the end of your plugins
                          p/elide-special-outputs-plugin]}))

šŸ‘ 3
wilkerlucio22:06:47

and nothing wrong with your google-fu, just not well documented

šŸ‘ 2
lsenjov22:06:58

Iā€™m not looking to replace every instance of not found, just the ones I know are nil. Would writing a plugin that replaces something like ::p/nil with nil on output be a reasonable solution?

wilkerlucio22:06:55

if you look into the p/elide-special-outputs-plugin, you can copy and modify it

wilkerlucio22:06:14

(def elide-special-outputs-plugin
  (post-process-parser-plugin elide-special-outputs))

wilkerlucio22:06:20

(defn elide-special-outputs
  "Convert all ::p/not-found values of maps to nil"
  [input]
  (elide-items special-outputs input))

wilkerlucio22:06:27

(def special-outputs #{::reader-error ::not-found})

wilkerlucio22:06:07

so, something like: (p/post-process-parser-plugin #(elide-items #{::p/not-found} %))

lsenjov22:06:06

Oh I see! Thank you for the help šŸ™‚

wilkerlucio11:06:15

oh, I just see there is p/elide-not-found that does it already