Fork me on GitHub

Hej @kwladyka 👋 Long time no see. 😉 I've attached some notes on how I think about resolvers:

👍 8

hello @pithyless 🙂 Very long time ! Thanks for example. I will relocate to Wrocław soon. Give me some news from your live 🙂 (maybe not on this channel 😉 )


@wilkerlucio is it possible to apply the batch transformer to a dynamic resolver?


(pc/defresolver get-shop [env {:shop/keys [uuid]}]
  {::pc/input #{:shop/uuid}
   ::pc/output [:shop/uuid :shop/name :shop/engine :shop/config]}
  (shop-biz/get-shop uuid))
(utils/request-eql [{[:shop/uuid "99999999-9999-9999-9999-999999999999"] [:shop/uuid :shop/name :shop/engine :shop/config]}])
#:shop{:uuid "99999999-9999-9999-9999-999999999999",
       :engine :com.wsscode.pathom.core/not-found,
       :name :com.wsscode.pathom.core/not-found,
       :config :com.wsscode.pathom.core/not-found}
What is the best practice? Can I return clear information when the shop is not found? Or is good like it is for EQL?


I feel :com.wsscode.pathom.core/not-found is a bad idea


If you return just {:shop/uuid ".."} , then Pathom will try a different resolver that has :shop/engine . So, if you're sure that there is no :shop/engine for this case, you want to return something. You can e.g. return {:shop/engine nil} , but then you need to be sure that whoever is parsing the result will be ok with handling a nil engine correctly. You can also return {:shop/engine :com.wsscode.pathom.core/not-found} and then use a parser plugin (e.g. elide-special-outputs-plugin) to remove the not-found values before returning the result to the client.

👍 4

(pc/defmutation update-shop [env params]
  {::pc/sym 'shop/update
   ::pc/params #{:shop/name :shop/engine :shop/config}
   ::pc/output [:shop/uuid]}
  (shop-biz/update-shop params)
  (-> (select-keys params [:shop/uuid])
      (update :shop/uuid str))
  {:shop/uuid #uuid"11111111-1111-1111-1111-111111111111"})
I found resolvers are not called with #uuid but works without.
(pc/defresolver get-shop [env params]
  {::pc/input #{:shop/uuid}
   ::pc/output [:shop/name :shop/engine :shop/config]
   ::pc/transform pc/transform-batch-resolver}
  (println "foo" (shop-biz/get-shops (set (map :shop/uuid params))))
  (shop-biz/get-shops (set (map :shop/uuid params))))
I don’t see println with #uuid . Why?



:shop/uuid #uuid"11111111-1111-1111-1111-111111111111"
if I use #uuid in EQL query I have to return str. But if I use string in EQL query
:shop/uuid "11111111-1111-1111-1111-111111111111"
I can return #uuid or str This is a little unpredictable