This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-19
Channels
- # adventofcode (1)
- # announcements (3)
- # babashka (60)
- # beginners (60)
- # calva (5)
- # clj-commons (17)
- # clj-kondo (33)
- # clj-on-windows (1)
- # clojure (40)
- # clojure-austin (3)
- # clojure-europe (19)
- # clojure-gamedev (25)
- # clojure-nl (1)
- # clojure-norway (6)
- # clojure-sweden (4)
- # clojure-uk (2)
- # clojurescript (27)
- # conjure (1)
- # core-async (1)
- # core-typed (7)
- # cursive (5)
- # datomic (35)
- # events (1)
- # fulcro (35)
- # integrant (7)
- # introduce-yourself (2)
- # kaocha (5)
- # leiningen (2)
- # lsp (26)
- # malli (13)
- # nbb (99)
- # off-topic (15)
- # pathom (12)
- # pedestal (5)
- # polylith (8)
- # portal (4)
- # rdf (19)
- # reagent (8)
- # reitit (5)
- # releases (2)
- # remote-jobs (2)
- # rewrite-clj (1)
- # shadow-cljs (94)
- # testing (2)
- # timbre (2)
- # tools-deps (16)
How do you write a resolver for a recursive datastructure?
Does this help? https://edn-query-language.org/eql/1.0.0/specification.html#_recursive_queries
Well how do I tell Pathom that the output of the resolver is a nested tree?
So obviously you can make a resolver that has the output [:id {:children [:id]}]
that resolver can answer a recursive query…
But it will be called for each node once. And I get the whole tree in a single DB query.
if you return the entire tree pathom will just return it and not continue calling the resolver
i've used that in the past as an optimization - calling db/pull directly instead of having nested pathom calls
If you want to keep the decomposition into resolvers, you can also leverage batching in pathom3. let's say you have a resolver that gets a list of IDs, one that gets the attributes, and maybe a nested one that gets nested attributes from the db It will only take 3 queries, 1 per resolver, if you write batch queries In pathom2 that wasn't working for nested attributes