pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
lsenjov 2021-06-17T21:56:07.100800Z

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

wilkerlucio 2021-06-18T11:30:15.103400Z

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

wilkerlucio 2021-06-17T21:59:33.101Z

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

šŸ‘ 1
wilkerlucio 2021-06-17T22:00:47.101300Z

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

šŸ‘ 1
lsenjov 2021-06-17T22:01:58.101500Z

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?

wilkerlucio 2021-06-17T22:02:55.101800Z

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

wilkerlucio 2021-06-17T22:03:14.102Z

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

wilkerlucio 2021-06-17T22:03:20.102200Z

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

wilkerlucio 2021-06-17T22:03:27.102400Z

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

wilkerlucio 2021-06-17T22:04:07.102600Z

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

lsenjov 2021-06-17T22:07:06.102900Z

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