pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
nivekuil 2021-01-28T13:36:31.081500Z

the plugins are so much nicer to write in pathom 3!

nivekuil 2021-01-29T08:36:15.094Z

probably should be you, I don't know enough about best practices :)

wilkerlucio 2021-01-28T14:23:50.081800Z

thanks 🙂 what change you found made it nicer in your opinion?

nivekuil 2021-01-28T14:31:59.082Z

it's much shorter, for one.

(def mulog-trace-plugin -  {::pc/wrap-resolve -   (fn [resolver] -     (fn [env input] -       (u/trace (-> env ::pc/resolver-data ::pc/sym keyword) -         [] -         (resolver env input)))) -   ::p/wrap-mutate -   (fn [mutate] -     (fn [env k params] -       (let [out (mutate env k params)] -         (cond-> out -           (:action out) -           (update :action -                   (fn [action] -                     (fn [] -                       (u/trace (keyword k) -                         [] -                         (action)))))))))})
vs
(defplugin mulog-trace-plugin   {::pcr/wrap-resolve    (fn [resolver]      (fn [env node]        (u/trace (-> node ::pco/op-name str) []                 (resolver env node))))    ::pcr/wrap-mutate    (fn [mutation]      (fn [env ast]        (u/trace (-> ast :key str) []                 (mutation env ast))))})

nivekuil 2021-01-28T14:33:05.082200Z

it generally just feels much smoother to work with operations directly, as you can call them like functions and mutations/resolvers seem to share more structure than in p2

nivekuil 2021-01-28T14:35:24.082400Z

more fun to work with means I actually write plugins. for example, I think pc/transform is not in p3 but it was really easy to just write a custom plugin to replace it

nivekuil 2021-01-28T14:43:56.082600Z

in general I think a lot of small changes added up to make p3 feel much more streamlined

wilkerlucio 2021-01-28T17:10:58.083200Z

thank you very much for the feedback 🙏

wilkerlucio 2021-01-28T17:11:10.083400Z

yeah, mutation plugins were a real pain in the ass in Pathom 2

wilkerlucio 2021-01-28T17:11:42.083600Z

just one thing to note though, what you get in the plugin isn't the resolver, neighter the mutation

wilkerlucio 2021-01-28T17:11:53.083800Z

its the functions that wrap their call inside the runner

wilkerlucio 2021-01-28T17:12:11.084Z

if you want to access the actual resolver or mutation, you must use the node on resolver, and ast + index in the mutation

nivekuil 2021-01-28T17:44:44.084200Z

yeah, I figured out something like this: (get-in env [::pci/index-mutations (:key ast) :config]) not sure if it's mentioned in the docs

wilkerlucio 2021-01-28T17:45:54.084400Z

no, if you like to add PR is welcome, or I can put in a todo list here