pathom 2024-08-23

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}

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.

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}

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

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

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

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

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.

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