Fork me on GitHub
#pathom
<
2022-03-08
>
danieroux14:03:36

What am I missing here regarding parameters for pathom3?

(def eql-with-params
  ['({[:asset/id 13] [:asset.series/level]}
     {:time.series/from #inst "2021-12-11T00:00:00.000-00:00",
      :time.series/to #inst "2021-12-16T00:00:00.000-00:00"})])

(pco/defresolver series-resolver [env _]
  {:asset.series/level {:params-expected-but-is-empty (pco/params env)}})

(def env (pci/register series-resolver))

(p.eql/process env eql-with-params)

=> {[:asset/id 13] {:asset.series/level {:params-expected-but-is-empty {}}}}

wilkerlucio14:03:33

hello, the problem is the position of the params, in this example the params is set at the ident level, and params don't flow down (they are only acessible at the place they were defined)

wilkerlucio14:03:29

this is the query to send the params at the right place in your case:

(def eql-with-params
  ['{[:asset/id 13]
     [(:asset.series/level
        {:time.series/from #inst "2021-12-11T00:00:00.000-00:00",
         :time.series/to   #inst "2021-12-16T00:00:00.000-00:00"})]}])

wilkerlucio21:03:53

this issue is about a conceptually mismatch in this case, for Fulcro it thinks the params are "entity level", but for Pathom the params are "per attribute", the common solution in Fulcro with Pathom 2 is to use Pathom plugin that forwards down the params from a parent entity via environment

wilkerlucio21:03:16

another thing I believe (have to test) you can do is to put the param strait in the query, instead of using the fulcro :params thing

wilkerlucio21:03:42

the plugin solution doesn't exist afaik for Pathom 3 yet

markaddleman15:03:20

In Pathom3, I use the three arity p.eql/process to keep the query separate from the entity. My "params" are folded into the entity map. I haven't encountered any problems taking this approach but I'm wondering if there is any advantage to keeping "params" separate from the entity