I suspect I'm missing something silly here, but how do I do the initial entity lookup? My query looks like this:
[{[:user/id #uuid "5f3bf49f-36fa-41a8-88dd-09ca67f8392f"]
[:db/id]}]
I'm pretty sure I want a resolver (not a reader), but not positive. I expected it to convert [:user/id #uuid "5f3bf49f-36fa-41a8-88dd-09ca67f8392f"]
to {:user/id #uuid "5f3bf49f-36fa-41a8-88dd-09ca67f8392f"}
internally and trigger my {::pc/input #{:user/id} ::pc/output [:db/id]}
resolver, but it never runs. Is there a simple example of this somewhere? I can't find it in the docs.You have to use an ident reader for pathom to understand idents.
E.g. pc/open-ident-reader
can you please share the parser setup? the query looks correct, maybe there is some setup missing
Yeah, here's the whole thing.
I should mention, this is pathom 2.2.31.
one minor error in the example code is that you define p
and try to call parser
this is working here (minor changes to your code, so I don't depend on datascript/datomic):
(pc/defresolver user-resolver
[{:keys [db]} {:keys [user/id]}]
{::pc/input #{:user/id}
::pc/output [:db/id]}
(println :user-resolver) ;; never prints
{:db/id (get-in db [:user/id id])})
(def p
(p/parser
{::p/env {::p/reader [p/map-reader
pc/reader2
pc/open-ident-reader
p/env-placeholder-reader]}
::p/plugins [(pc/connect-plugin {::pc/register [user-resolver]})
p/error-handler-plugin]}))
(comment
(let [db {}]
(p {:db db}
[{[:user/id #uuid "5f3bf49f-36fa-41a8-88dd-09ca67f8392f"]
[:db/id]}]))
)
(let [db {}]
(p {:db db}
[{[:user/id #uuid "5f3bf49f-36fa-41a8-88dd-09ca67f8392f"]
[:db/id]}]))
:user-resolver
=> {[:user/id #uuid"5f3bf49f-36fa-41a8-88dd-09ca67f8392f"] #:db{:id nil}}
Oh geez. 🤦
I guess I was missing something silly. Thanks for taking a look.
no worries, glad to help