Fork me on GitHub
#pathom
<
2023-05-08
>
sheluchin15:05:33

(do
  (pco/defresolver items
    [env qp]
    {::pco/input [:limit]}
    (tap> {:qp qp
           :params (pco/params env)})
    {:items [{:item/id 1}
             {:item/id 2}
             {:item/id 3}]})

  (pco/defmutation item-writer
    [env params]
    {::pco/params [{:items [:item/id]}
                   :limit]}
    (print (:limit params)))

  (p.eql/process (-> (pci/register [items item-writer])
                     (p.plugin/register pbip/mutation-resolve-params))
    [`(item-writer {:limit 2})]))
tap> {:qp {:limit 2}
      :params {}}
2
=> {playgrounds.pathom/item-writer nil}
Is there a way to call a mutation with some params and also have access to those params in the resolver used in the mutations ::pco/params? I have it somewhat working here, but the resolver has to accept the params as inputs which doesn't seem like the right semantics. I could also change the defmutation like so:
{::pco/params [{'(:items {:some-param "xyz"}) [:item/id]}
                   :limit]}
in which case the "xyz" does make it to the resolver, but I want this to be a dynamic value. I'm ultimately trying to create a defmutation that receives its inputs from a resolver and I want the mutation to support pagination paramaters.