pathom

Joe R. Smith 2024-08-23T20:39:55.381139Z

Using Pathom3, passing params to multiple properties that are handled by a single resolver does not appear to work. e.g.: Given the resolver definition:

(defresolver param-test
  [env _]
  {::pco/output [:some/thing :some/other]}
  (let [params (pco/params env)]
    {:some/thing (get params :a)
     :some/other (get params :b)}))
and the query:
[(:some/thing {:a 3})
 (:some/other {:b 5})]
The result is:
{:some/thing 3, :some/other nil}
The value of (pco/params env) is {:a 3}

Joe R. Smith 2024-08-24T15:13:46.478929Z

One other question I had-- is it possible or should it be possible to specify which property you're getting params for? E.g., if I pass params like :max-results to two properties and they're handled by the same resolver, currently I couldn't differentiate between them unless I used property-specific params, e.g. :prop-a/max-results and :prop-b/max-results.

Joe R. Smith 2024-08-24T15:20:26.570369Z

With how it works now if you pass the same param to two properties (after the fix above) is:

[(:some/thing {:a 3})
 (:some/other {:a 5})]))
result:
{:some/thing 5, :some/other nil}

Joe R. Smith 2024-08-24T15:21:24.254839Z

maybe a pco/params that takes a second arg, the property name?

wilkerlucio 2024-08-24T16:28:03.830139Z

params should be though at resolver leve, so that its a bit weird conceptually, but that said, its doable, if you look at the ::pcp/index-ast on the graph (available at ::pcp/graph in the env), it indexes each property, and you can extract attribute params from it

wilkerlucio 2024-08-24T16:28:32.218089Z

(altough, the nil would be expected in :some/other since you didn't provided param :b, right?)

wilkerlucio 2024-08-24T16:30:40.907139Z

I'm not willing to add that to the lib at the moment, but you can easely write a helper for yourself to extract it

👍 1
Joe R. Smith 2024-08-24T16:37:32.842779Z

yes, that example was a little confusing- I was trying to demonstrate that only one of the two :a params would be visible from pco/params, and in this case it is 5.

Joe R. Smith 2024-08-24T16:38:19.952329Z

but I understand the convention you're suggesting-- have a separate resolver for each parameterized property

wilkerlucio 2024-08-23T23:11:10.219259Z

https://github.com/wilkerlucio/pathom3/issues/216

👍 1
👀 1