Fork me on GitHub

@wilkerlucio Is there a special parser/reader required so ::pc/transform (pc/transform-auto-batch 10) works? I'm running on cljs and have async-parser, but all the requests are running consequently:


is this a recursive query? the batch only works for sibling entities, when driling down it currently just chains the process


[{([ "TKSbTbE6O5Q0U89JhuHc"] {:with "params"})


These are sibling entities and they are independent


Am I right that you can only have one ident per query?


If you have multiple inputs then you need to use :pathom/context ?


Aha, I just now realized that I can pass params to the (parser) through env. That makes my life muuuuch easier and queries are more readable now 🙂


Just out of curiosity, is there a small library anywhere for turning datomic pull expressions into ASTs -- if not, is there a library that deals only with transforming EQL to an AST ( though I realize datomic pull isn't a proper subset of EQL).


y'all rock. thanks


How can I pass in a vector of things into a resolver? For instance, I have a bunch of item id's. I would like to send 2+ ids into my resolver and have it determine the similarity between those ids (meaning I can't send in 1 idea at a time). Hopefully this example shows what I am trying to do:

(defresolver similar-traits [env {:keys [[item/id]]}]
  {::pc/input  #{[:item/id]}
   ::pc/output [:result]}
  {:result (get-result <ids somehow>)})


The second parameter in ident can be anything. So you can have ::pc/input #{:item/ids} and then use ident like [[:item/ids [:id1 :id2]]]


Can you please write out the whole resolver @bear-z? I can't seem to get it working. I'd like the resolver to know that it's a vector of :item/ids not just an object with an :item/ids key


I don't think you can do that unless it is a batch resolver. Try this:

(defresolver similar-traits [env input]
  {::pc/input  #{:item/id}
   ::pc/output [:result]
   ::pc/batch? true}
  {:result (get-result <your input will have a sequence of :item/id>)})
But batch resolvers will only be called when you have a sibling query (meaning they appear in joins), I don't think you can run them from the root.


For the root, you can just create this extra key that will expect to receive a vector of :item/id


@bear-z okay I think I understand now. One thing the docs don't provide is an example of how to actually pass that data into the parser. Do you know how to do that? I tried something like

(<!! ((du/get-parser) {} [{[{:item/id 1}
                            {:item/id 2}
                            {:item/id 3}]
but this yielded an error


That won't work because your query is invalid. Ident always a tuple of 2 elements. Is there a reason that you want resolver to get :item/id separately and not as a list? Because I think you're overcomplicating it. If it always takes a list and returns some computed result, why would you add an overhead of batching and stuff?


I don't know that batching is the answer I've only just learned about it. I just want to be able to send a vector of n {:item/id <id>}s into the parser and have a result computed. And I'm stuck on the n part. I have [{:item/id 1}{:item/id 2} ... {:item/id n}] . I can do something like

(defresolver ixn-similar-traits [env [:keys [item/ids]]]
  {::pc/input  #{:item/ids}
   ::pc/output [:result]}
  {:result (get-result ids)})
and then
(<!! ((du/get-parser) {} [{[:item/ids
                              [{:item/id 1}
                               {:item/id 2}
                               {:item/id 3}]]
but the resolver won't be able to check to ensure that :item/ids is actually a vector of maps with :item/id keys. I would like to further describe to the resolver that it should only work when receiving a vector of maps with :item/id keys. Expressed in edn [{:item/ids [:item/id]}]


You can add a spec inside resolver or even a simple assert


something like that:

(s/def ::item-map (s/keys :req [:item/id]))
(s/def ::items-coll (s/coll-of ::item-map))
And then inside your resolver simple: (s/valid? ::items-coll input) Full guide is here: