Fork me on GitHub
#fulcro
<
2022-02-28
>
hadils20:02:21

I am using Pathon 2 still. I need to write a resolver that takes an ident and a parameter. Despite my efforts to figure this out, I am unable to get the parameter in my resolver. Can someone show me an example of this, or help e? Thanks in advance!

sheluchin20:02:48

Can you please post the relevant parts of what you have so far?

lgessler20:02:37

The Pathom docs give a pretty clear example I think: https://blog.wsscode.com/pathom/#_parameters

hadils21:02:05

I am not able to get the parameters with (-> env :ast :params)

hadils21:02:13

Here is my code

(defresolver werkers-by-service-location-resolver
  [env {:location/keys [position] :service/keys [id] :as input}]
  {::pc/input  #{:location/position}
   ::pc/params [:service/id]
   ::pc/output [{:werkers-by-service-location [:werker/id]}]}
  (log/spy input)
  (log/spy (-> env :ast :params))
  {:werkers-by-service-location []})

sheluchin21:02:59

I believe ::pc/params is for pc/defmutation and not pc/defresolver.

hadils21:02:18

I took it out, no change.

sheluchin21:02:24

And the parameter will not be coming in the input argument (second one) of the resolver, it's in the env.

Jakub Holý (HolyJak)21:02:38

so you query for [([:location/position "something"] {:service/id 123})] but you do not see the 123 anywhere inside the env / ast?

sheluchin21:02:20

Can you show the query portion please?

hadils21:02:03

[({[:location/zipcode "85286"] [:werkers-by-service-location]} {:service/id #uuid "ffffffff-ffff-ffff-ffff-000000000100"})]

hadils21:02:45

I have a resolver from :location/zipcode to :location/position It is working properly.

hadils21:02:47

I see a position in my input to my resolver.

sheluchin21:02:17

Is the zipcode resolver receiving the param?

hadils21:02:06

Ah. Maybe so…

hadils21:02:05

Nope. That’s not it. Here’s the output: (-> env :ast) => {:type :prop, :dispatch-key :werkers-by-service-location, :key :werkers-by-service-location}

Jakub Holý (HolyJak)21:02:39

I can replicate it, Using my minimalist-fulcro-template-backendless' person resolver, the env contains :ast {:type :prop, :dispatch-key :person/name, :key :person/name} and the only place that seems to have the params is :com.wsscode.pathom.core/root-query which is [({[:person/id 1] [:person/name]} {:service/id 123})]

sheluchin21:02:24

I think I recall running into situations where a join param didn't work but placing the param on the ident did. Try that?

Jakub Holý (HolyJak)21:02:27

Fulcro only supports params at the top level. The query above was actually generated by (df/load! [:person/id 1] (rc/nc '[:person/name]) {:params {:service/id 123}})

1
hadils21:02:18

So, any suggestions on how to parse the ::p/root-query?

Jakub Holý (HolyJak)21:02:11

I would ask @U066U8JQJ for help figuring out why the params are inside root-query but not inside :ast , as https://clojurians.slack.com/archives/C68M60S4F/p1646083719605539?thread_ts=1646081061.832729&amp;cid=C68M60S4F. I think the fact that the ast being {:type :prop, :dispatch-key :person/name ...} indicates that we are kind of "one level down" in the ast and we would need to get to the parent level, where :type join to see the params. I am not sure how this is supposed to work.

hadils21:02:00

Thank you @U0522TWDA.

🙏 1
Jakub Holý (HolyJak)21:02:06

The plugin works indeed - after adding it, the env has :query-params {:service/id 123}

🙂 1
👍 1
hadils21:02:07

I confirm that @U0522TWDA. Thanks again for your help!!!!!