Fork me on GitHub
#pathom
<
2021-01-11
>
MatthewLisp13:01:15

Hello 👋

👋 21
wilkerlucio16:01:10

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

parrot 6
👏 12
clojure-spin 3
😍 3
markaddleman21:01:08

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.

wilkerlucio22:01:11

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?

markaddleman22:01:48

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

markaddleman22:01:43

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.

markaddleman22:01:14

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

wilkerlucio23:01:39

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

wilkerlucio23:01:33

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

wilkerlucio23:01:42

(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"}