I'm having trouble with query parameters. My query is
'[{([:a "value"] {:with "params"})
[:b :c]}]
Which, I believe matches the syntax for ident joins described at https://edn-query-language.org/eql/1.0.0/specification.html#_parameters
The ast does not include the parameter mapThe ast for query
'[{[:a "value"]
[(:b {:with "params"}) :c]}]
includes parameters but I don't think this syntax matches the spec. From what I understand, I also don't think this query makes sensei'm using pathom 2.3.0-alpha8
you can see how your queries get parsed with eql lib:
(eql/query->ast
'[{([:a "value"] {:with "params"})
[:b :c]}]
)
=>
{:type :root,
:children [{:type :join,
:dispatch-key :a,
:key [:a "value"],
:params {:with "params"},
:meta {:line 2, :column 8},
:query [:b :c],
:children [{:type :prop, :dispatch-key :b, :key :b} {:type :prop, :dispatch-key :c, :key :c}]}]}
from that it looks like it's parsing as you expected - an ident join with params. Are the params not in your resolver?
[{([:a "value"] {:with "params"})
[:b :c]}]
The resolver does not receive the params for that ^^ query
That query's ast is
{:type :prop, :dispatch-key :b, :key :b}
ok I see. It will be hard to debug without your resolver code and maybe an example of invoking the parser and logging what the resolver's input and (:ast env) are
Here's a repro case:
(pc/defresolver param-resolver [env _]
{::pc/input #{:a}
::pc/output [:b :c]}
(clojure.pprint/pprint (:ast env))
{:b 1, :c 2})
(def parser
(p/parser
{::p/env {::p/reader [p/map-reader
pc/reader2
pc/open-ident-reader
p/env-placeholder-reader]
::p/placeholder-prefixes #{">"}}
::p/mutate pc/mutate-async
::p/plugins [(pc/connect-plugin {::pc/register [param-resolver]}) ; setup connect and use our resolvers
p/error-handler-plugin
p/trace-plugin]}))
(parser {} '[{([:a "value"] {:with "params"})
[:b :c]}])
I'm sure there's a pathom plugin to log the ast parsing but my pathom foo isn't up to it 🙂
ok I tried it out and I'm not seeing the params coming through to the resolver either. They are in the transaction though, before being processed by the resolver. I'm not sure why that is, but to get this working you can use the plugin in fulcro-rad to pass params as a top level key :query-params in the env: https://github.com/fulcrologic/fulcro-rad/blob/develop/src/main/com/fulcrologic/rad/pathom.clj#L108 Then pull them off any resolver using (:query-params env)
Ok, so I'm a pathom newbie and I'm not using fulcro. From my understanding, I don't think the plugin from fulcro-rad has any dependency on fulcro - so that's good. Does it the ordering of the rad plugin matter relative to the connect plugin?
np, you can just copy paste it 🙂
i'm not sure about ordering with plugins, but i have it after the connect plugin