Fork me on GitHub

I'm trying to understand the best way to create a mutation that uses resolve params and paginates the parameter inputs. Here's what I've come up with:

  (pco/defresolver items
    [env {:keys [limit offset] :as _input}]
    ;; :exclamation: set as optional inputs on resolver, but come in as parameters to
    ;;    mutation
    ;; the inputs are passed in the call to `p.eql/process` as part of the `tx`
    {::pco/input [(pco/? :limit)
                  (pco/? :offset)]
     ::pco/output [{:items [:item/id]}]}
    (tap> {:input _input
           :limit limit
           :pco/params (pco/params env)})
          ; offset (or offset 0)]
    ;; just adds paginations support (`limit`/`offset`)
    {:items (let [items [{:item/id 1}
                         {:item/id 2}
                         {:item/id 3}]
                  limit (or limit 2)
                  offset (or offset 0)
                  page (->> items
                            (drop offset)
                            (take limit)

  (pco/defmutation item-writer
    [env params]
    ;; :items comes from the resolver up top
    {::pco/params [{:items [:item/id]}]}

  (p.eql/process (-> (pci/register [items item-writer])
                     ;; :exclamation: uses this plugin
                     (p.plugin/register pbip/mutation-resolve-params))
    [`(item-writer {:limit 2})]))
=> {playgrounds.pathom/item-writer {:items [{:item/id 1}
                                            {:item/id 2}]}}
• what I find strange about this solution is the behaviour of inputs and parameters: • invoking a mutation with some parameters: ◦ defmutation receives them in the 2nd params argument ◦ defresolver receives them in the 2nd inputs argument: ◦ resolvers normally receive parameters in the 1st env argument: ▪︎ retrieved with (pco/params env)😕 given the above, what is the right way to write a resolver that can be used directly, or as part of a defmutation call? Anyone have any feedback on this? Is there a better way to do it? I'm also curious about how to write a mutation that'll paginate over its inputs, but consume the entire data set. I'm guessing the only way to do that is by calling resolvers directly inside the mutation instead of using mutation-resolve-params.