Fork me on GitHub
#pathom
<
2021-04-15
>
cjsauer21:04:52

Is it necessary to specify ::pc/output of a resolver? I’ve noticed that if I don’t query for any keys that exist in the ::pc/output vector, then my resolver stops working (all keys are :not-found).

wilkerlucio22:04:19

yes, that’s required, there are a few cases in which Pathom can infer the output, but only very simple cases, for the most part you need to define the output

cjsauer22:04:19

Ah right. It took me too long to realize, but without the output you wouldn’t know which resolver to actually call…

cjsauer21:04:54

But if I query for even one key that matches what’s in ::pc/output, now it’s able to find keys that weren’t declared ahead of time.

wilkerlucio22:04:41

this happens because pathom just merges the result, and them you kind get it by accident

wilkerlucio22:04:14

think that pathom uses ::pc/output to generate the attribute index, if you try to lookup for something and its not there, pathom will make it not-found

wilkerlucio22:04:03

this is how you can get the “work by accident” case:

(pc/defresolver x []
  {::pco/output [:a]}
  {:a 1 :b 2})

(parser [:a :b])

wilkerlucio22:04:38

the :a attribute made pathom call x, which had the full result merged (`{:a 1 :b 2}`), now, when looking for :b it sees its already on the entity data, so it works

wilkerlucio22:04:45

but if you remove :a from this query (as : (parser {} [:b])), it wont, because :b isn’t indexed