pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
markaddleman 2020-05-24T15:51:54.077300Z

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 map

markaddleman 2020-05-24T15:53:02.077400Z

The 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 sense

markaddleman 2020-05-24T15:56:14.077600Z

i'm using pathom 2.3.0-alpha8

2020-05-24T16:33:17.077800Z

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}]}]}

2020-05-24T16:35:46.078Z

from that it looks like it's parsing as you expected - an ident join with params. Are the params not in your resolver?

markaddleman 2020-05-24T16:43:32.078200Z

[{([:a "value"] {:with "params"})
                [:b :c]}]

markaddleman 2020-05-24T16:43:49.078500Z

The resolver does not receive the params for that ^^ query

markaddleman 2020-05-24T16:45:08.078700Z

That query's ast is

{:type :prop, :dispatch-key :b, :key :b}

2020-05-24T16:49:00.078900Z

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

markaddleman 2020-05-24T16:51:35.079100Z

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]}])

markaddleman 2020-05-24T16:52:57.079300Z

I'm sure there's a pathom plugin to log the ast parsing but my pathom foo isn't up to it 🙂

2020-05-24T17:14:55.079500Z

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)

markaddleman 2020-05-24T17:17:44.079800Z

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?

2020-05-24T17:18:17.080Z

np, you can just copy paste it 🙂

2020-05-24T17:19:03.080200Z

i'm not sure about ordering with plugins, but i have it after the connect plugin

👍 1