pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
exit2 2020-10-05T16:36:59.027200Z

What is the typical way of setting up a resolver where you might not know all the outputs from the api response something like:

exit2 2020-10-05T16:37:25.027500Z

(pc/defresolver some-resolver
                [__ {:keys [resource/id]}]
                {::pc/input #{:resource/id}
                 ::pc/output [:id]}
                (let [resource (get-resource-by-id id)]
                  resource))

exit2 2020-10-05T16:37:42.027700Z

where I could still query other parts of the response like: `[{[:resource/id 1] [:id :name]}]`

wilkerlucio 2020-10-05T18:46:43.027800Z

You can do something similar to converting promises to channels wrapping one in another. In the end you need to provide a channel (a promise-channel preferably) to Pathom, some ways you can make it easier on you are: - create a ::pc/transform operation, so you can easely plug specific resolvers to accept manifold - if you wanna use it a lot, you can wrap a plugin using ::pc/wrap-resolve so you can detect manifold outputs and convert then to core.async channels

wilkerlucio 2020-10-05T18:47:32.028400Z

@njustice Pathom needs to know the output ahead of time, otherwise it can't figure the proper resolve to call an attribute

wilkerlucio 2020-10-05T18:47:37.028600Z

so you can't have that open

wilkerlucio 2020-10-05T18:47:58.029300Z

dynamic resolvers can be a bit more cherry picking on it, but they still need to know all possibilities ahead of time

Michael W 2020-10-05T18:50:42.031800Z

You sort of can have it open, if you build a resolver by id, but have it return all data, you can then use something like filter to pull out what you need. fulcro-rad-demo does it with attributes that have a name starting with "all-". But pathom won't be able to query by any of that output unless it's in the output list.

exit2 2020-10-05T18:52:33.032400Z

@wilkerlucio in my example, I get back the :name w/o including it in the pc/output

exit2 2020-10-05T18:56:29.037400Z

I.e. `{[:resource/id 1] {:name "foo", :id 1}}`

wilkerlucio 2020-10-05T18:56:33.037600Z

@njustice the problem is that this makes it a an implicit dependency, in a way its like getting it by accident. the problem is that if you don't ask for the id, you will never get :name. also, I like to discourage you from having unqualified attributes in the system (input or output) due that it will easaly collide with other things

exit2 2020-10-05T18:57:16.038600Z

so for any resource I have, if I want to use a field from it, I need to include it in the output

tvaughan 2020-10-06T14:57:47.039900Z

Or stuff them all into a hash-map under one key. The contents of the hash-map under this key become arbitrary

wilkerlucio 2020-10-05T18:57:33.038900Z

yes, you can think of it as your schema in a way

exit2 2020-10-05T18:57:47.039300Z

gotcha