pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
markaddleman 2020-05-22T14:03:13.073700Z

I'm on my pathom learning journey and am running into a problem that makes me think I'm missing some fundamental concept. In the docs, there's the latest-product resolver. I want to extend that to take an input and return a list of products. For example, I want to provide a store id and return the list of latest products for that store. Here are the resolver and query that don't work. What am I doing wrong?

(pc/defresolver latest-products-for-store [_ {::keys [store]}]
  {::pc/input  [::store]
   ::pc/output [{::store [:product/id :product/title :product/price]}]}
  (condp = store
    0 {[::store 0] [{:product/id    1
                     :product/title "Acoustic Guitar"
                     :product/price 199.99M}
                    {:product/id    2
                     :product/title "Piano"
                     :product/price 99.99M}]}
    1 {[::store 1] [{:product/id    3
                     :product/title "Clavachord"
                     :product/price 199.99M}
                    {:product/id    4
                     :product/title "Didgeridoo"
                     :product/price 990.99M}]}))
query:
[{[::store 1] [:product/id]}]

markaddleman 2020-05-22T14:06:42.073800Z

typo in my example the ::pc/input ought to be a set instead of a vector. That doesn't change the result. The parser still returns not found

markaddleman 2020-05-22T14:50:42.074Z

I found the issue: The output attribute is the same name as the input attribute (ie ::store) Of course, that makes no sense

2020-05-22T16:40:51.074200Z

nice find, I've struggled with typos and keys not matching. Maybe the defresolver macro can be enhanced to support some basic type checking like that

👍 1