WSSCode Blog

Pathom Updates 4

November 27, 2020

Lots of goodies add since the last update. Let’s go through them:

Resolver parameters

Pathom 3 now supports resolver parameters. Check details at the parameters documentation.


Mutations support got in this week, documentation is also up.


Dear placeholders, the most confusing but quite useful feature, learn more about it in the documentation.

One difference to note, now placeholders support params to update the data in that context.


Union queries also landed in Pathom 3! Unions documentation.


Batch is now available on Pathom 3!

The way to use is still similar to Pathom 2; one thing changed, now on the user side, a batch resolver will always receive a sequence and always return a sequence. In contrast with the previous interface, which could be a sequence or a single item.

The implementation is entirely new. In Pathom 2, the way batch works is by holding a reference to a processing sequence in the env, and when a batch resolver is reached it can look back on that list to pull all the inputs for the batch.

In Pathom 3, it works differently. It doesn’t hold any processing sequence. Instead, when it reaches a batch resolver, it pauses the execution of that graph, stores that batch step in a list, and moves on. Once everything else is done (including going over other graphs/entities), it sees all the demand for batching and run at once.

A practical difference of that is that now Pathom supports multi-level batching! Let me show you what this means. First we will start with a basic example:

(pco/defresolver batch-fetch [items]
  {::pco/input  [:id]
   ::pco/output [:v]
   ::pco/batch? true}
  (println "CALL")
  (mapv #(hash-map :v (* 10 (:id %))) items))

(def env
  (pci/register batch-fetch))

  (p.ent/with-entity env
    {:list [{:id 1}
            {:id 2}
            {:id 3}]})
  [{:list [:v]}])
; => CALL
;    {:list [{:v 10} {:v 20} {:v 30}]}

As we can see, for the 3 items on the list, Pathom calls the batch resolver once. This works the same as in Pathom 2, now for the different case:

  (p.ent/with-entity env
    {:list [{:items [{:id 1}
                     {:id 2}]}
            {:items [{:id 3}
                     {:id 4}]}
            {:items [{:id 5}
                     {:id 6}]}]})
  [{:list [{:items [:v]}]}])
{:list [{:items [{:v 10} {:v 20}]}
        {:items [{:v 30} {:v 40}]}
        {:items [{:v 50} {:v 60}]}]}

Note this time the batch children are present at different levels, in Pathom 2 that calls the batch resolver three times, with two items each time. Pathom 3 makes a single call to the batch resolver, with the six inputs at once.

I’m still working on the docs for the batch, should be out soon!

This is all for this update. See you at the next one!

Follow closer

If you like to know in more details about my projects check my open Roam database where you can see development details almost daily.

Support my work

I'm currently an independent developer and I spent quite a lot of my personal time doing open-source work. If my work is valuable for you or your company, please consider supporting my work though Patreon, this way you can help me have more available time to keep doing this work. Thanks!

Current supporters

And here I like to give a thanks to my current supporters:

Albrecht Schmidt
Austin Finlinson
Daemian Mack
Kendall Buchanan
Mark Wardle
Michael Glaesemann
Oleg, Iar, Anton