pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
MatthewLisp 2021-01-11T13:00:15.178400Z

Hello πŸ‘‹

πŸ‘‹ 6
wilkerlucio 2021-01-11T16:57:10.179700Z

New docs section on using Recursive queries with EQL on Pathom 3: https://pathom3.wsscode.com/docs/eql/#recursive-queries

πŸ‘ 5
1
😍 1
🦜 3
ChicΓ£o 2021-01-11T20:59:35.180400Z

Hello!

markaddleman 2021-01-11T21:31:08.183900Z

Have you given any thought to multimethod-like dispatch for resolvers? For example, I might have a compute-cost resolver that dispatches based on an input parameter product/type to resolvers compute-book-cost and compute-fish-cost that have different inputs. I can see how I might use optional inputs to achieve the desired result but that approach seems a little messy.

wilkerlucio 2021-01-11T22:46:11.184Z

not sure if I understand the issue, you can already have multiple options for the same value (multiple resolvers with same output, different input), with different dependencies. can you make an example?

markaddleman 2021-01-11T22:56:48.184300Z

I have a use case of two resolvers taking different inputs and producing the same output.

markaddleman 2021-01-11T22:57:43.184500Z

When the inputs for resolver A are satisfied, I'd like Pathom to execute that resolver. When the inputs for resolver B are satisfied, obviously execute the other.

markaddleman 2021-01-11T22:59:14.184700Z

I can see a way to implement this in Pathom 3 using optional inputs but it seems a little messy.

wilkerlucio 2021-01-11T23:29:39.184900Z

you don't need optional input, just make 2 resolvers with the same output, the exact thing you described is what pathom does

wilkerlucio 2021-01-11T23:32:33.185400Z

code in Pathom 3 (but works the same in Pathom 2):

wilkerlucio 2021-01-11T23:32:42.185600Z

(pco/defresolver c-from-a [{:keys [a]}]
  {:c (str a "A")})

(pco/defresolver c-from-b [{:keys [b]}]
  {:c (str b "B")})

(def paths-env (pci/register [c-from-a c-from-b]))

(p.eql/process paths-env {:a 1} [:c])
=> {:c "1A"}
(p.eql/process paths-env {:b 2} [:c])
=> {:c "2B"}

wilkerlucio 2021-01-11T23:35:10.185800Z

makes sense?

markaddleman 2021-01-11T23:45:30.186Z

Thanks. I'm pretty sure I ran into issues trying to make this work in the past. Perhaps because my two resolves have an overlapping set of inputs... I don't recall the specifics but c-from-a might take keys [a z] and c-from-b might take keys [b z] . Now that I know it should work, I'll play around with it to see if I can reproduce my problem.

wilkerlucio 2021-01-11T23:55:23.186200Z

cool, please let me know if you find the issue. if you are hitting some edge case, its likely that Pathom 3 will do a better thing than pathom 2, complex dependency chains are better served in the new version πŸ™‚

πŸ‘ 1