Hello π
New docs section on using Recursive queries with EQL on Pathom 3: https://pathom3.wsscode.com/docs/eql/#recursive-queries
Hello!
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.
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?
I have a use case of two resolvers taking different inputs and producing the same output.
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.
I can see a way to implement this in Pathom 3 using optional inputs but it seems a little messy.
you don't need optional input, just make 2 resolvers with the same output, the exact thing you described is what pathom does
code in Pathom 3 (but works the same in Pathom 2):
(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"}
makes sense?
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.
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 π