Fork me on GitHub
#pathom
<
2024-01-16
>
countgizmo09:01:11

Hey everyone! Is it possible to pass params from one resolver to another? Or maybe I'm thinking about params all wrong.

countgizmo09:01:35

The issue is that params are going to the top-most resolver, but it also has an input from another resolver and I would like the params to be passed to that resolver as well without mentioning it in the query.

wilkerlucio13:01:28

hello, can you tell more about your use case?

countgizmo13:01:22

I'll try... I have a resolver that returns a bunch of companies using their links. But the resolver depends on an input from another resolver - the one that actually does the web call to get the data. Looks something like this:

(pco/defresolver get-company
  [{:keys [link]}]
  {::pco/input [:company-response]
   ::pco/output [:company]}
  {:company (parse-response company-response))})
When I pass params to the query like this
[{:companies
   ['(:company {:someparam 42})]}]
I can get that param in get-company resolver but I don't see the param in the resolver that's providing the :company-response input.

countgizmo13:01:24

Now that I'm looking at it again. Maybe the resolver that provides the network response can just be a function that I call from the get-company resolver. Then I can propagate the params as args in a function call. Maybe I'm just overcomplicating things 🙂

countgizmo09:01:11

The param in this case controls which query to add in the request and which function to use to parse the response. In the example I've posted the parsing is easy to determine, cause I have the param in the "top level" resolver. But I need a way to pass this information to the resolver that does the request.

countgizmo09:01:56

Actually, after experimenting with the code some more I've realized that I need two different resolvers because I will need to have two different outputs at the top level, like :company and :that-other-info So it's not a param situation it's just two different resolvers situation.

👍 1