Fork me on GitHub
#pathom
<
2021-09-14
>
caleb.macdonaldblack02:09:35

Is there a tool I can use to visualise my pathom3 index?

caleb.macdonaldblack03:09:42

In the pathom viz tool I get: > Entity data requires Pathom 2.4.0+ > Or latest Pathom 3 from Git I’m using [com.wsscode/pathom3 “2021.08.14-alpha”] do I need to be newer than that?

wilkerlucio23:09:31

still having issues? a common one is to use the wrong namespace to start the connector

souenzzo12:09:33

@caleb.macdonaldblack no. when this was written, the only way to get pathom3 was from git. these alpha releases are pretty new.

👍 2
plins21:09:16

Im trying to follow some pathom3 examples

(def users-db
  {1 #:acme.user{:name     "Usuario 1"
                 :email    ""
                 :birthday "1989-10-25"}
   2 #:acme.user{:name     "Usuario 2"
                 :email    ""
                 :birthday "1975-09-11"}})

; pull stored user info from id
(pco/defresolver user-by-id [{:keys [acme.user/id]}]
  {::pco/output
   [:acme.user/name
    :acme.user/email
    :acme.user/birthday]}
  (get users-db id))
so my code looks like
(def products {1 {:product/name           "Moog Voyager XL"
                  :finance/price-in-cents 400000}
               2 {:product/name           "Roland V-Drum"
                  :finance/price-in-cents 40000}
               3 {:product/name           "RME UFX II"
                  :finance/price-in-cents 100000}
               4 {:product/name           "UAD Satellite Octo"
                  :finance/price-in-cents 100000}
               5 {:product/name           "Beer"
                  :finance/price-in-cents 300}})

(pco/defresolver product-id->product
  [_ctx {:product/keys [id]}]
  [{::pco/input  [:product/id]
    ::pco/output [:product/name
                  :finance/price-in-cents]}]
  (get products id))
but Im getting
Syntax error macroexpanding com.wsscode.pathom3.connect.operation/defresolver at (src/reify/main.clj:61:1).
{:name product-id->product, :arglist [[:sym _ctx] [:map #:product{:keys [id]}]], :body [[#:com.wsscode.pathom3.connect.operation{:input [:product/id], :output [:product/name :finance/price-in-cents]}] (get products id)]} - failed: (fn must-have-output-visible-map-or-options [{:keys [body options]}] (or (map? (last body)) options)) spec: :com.wsscode.pathom3.connect.operation/defresolver-args
this solves the error
(pco/defresolver product-id->product
  [_ctx {:product/keys [id]}]
  [{::pco/input  [:product/id]
    ::pco/output [:product/name
                  :finance/price-in-cents]}]

  {:product/name (get-in products [id :product/name])
   :finance/price-in-cents (get-in products [id :finance/price-in-cents])})
but its a bit smelly, am I missing something?

cyppan21:09:58

You should remove the vector around your {::pco/input ...} in your defresolver

cyppan21:09:20

(pco/defresolver product-id->product
  [_ctx {:product/keys [id]}]
  {::pco/input  [:product/id]
    ::pco/output [:product/name
                  :finance/price-in-cents]}
  (get products id))

cyppan21:09:37

it should solve your problem

plins14:09:40

oh! I did missed that! thanks a lot @U0CL38MU1

👍 2