This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-17
Channels
- # announcements (7)
- # babashka (24)
- # beginners (11)
- # boot (16)
- # calva (46)
- # cider (5)
- # clara (3)
- # clj-kondo (2)
- # cljfx (5)
- # clojure (122)
- # clojure-brasil (26)
- # clojure-dev (20)
- # clojure-europe (20)
- # clojure-germany (1)
- # clojure-nl (1)
- # clojure-norway (54)
- # clojure-uk (2)
- # clojurescript (6)
- # core-matrix (23)
- # datomic (85)
- # graalvm (1)
- # honeysql (9)
- # hyperfiddle (31)
- # lsp (3)
- # malli (9)
- # nbb (2)
- # off-topic (15)
- # pathom (15)
- # pedestal (4)
- # polylith (5)
- # re-frame (5)
- # reitit (9)
- # releases (2)
- # shadow-cljs (63)
- # specter (4)
- # xtdb (7)
Is it possible to have resolvers return smart-maps?
I tried, but what I get back is normal maps and I can’t invoke new lookups
This idea might not be a good idea performance wise, but I was thinking it could be nice for expressiveness and optimise later
not a thing, the map that returns from resolver is merged on a parent map, IMO this feels quite a mess, if you use the smart map directly, you can already read all the keys, I dont see the point of trying to mix them
you can return anything, including an explicitly initialized smart map. doesn't sound like a great idea in general though since EQL is even more expressive
Yeah I tried explicitly initialized smart map, but I suspected it got merged like Wilker confirmed. I did succeed forwarding a smart map via metadata, but this forces me to know the structure and extract the metadata.
Anyway, thanks for the feedback. I guess i’m trying something weird. Will experiment a bit more
Is there an equivalent for passing query options to smart maps?
E.g. let say I have a resolver :users/list
that accepts the param :filter
what would be the equivalent of the following?
(p.eql/process env '[(:users/list {:filter :active})]`)
The below works, but I don’t know how to apply my param :filter
(:users/list (psm/smart-map env {}))
In analogy to the resolver I thought maybe this could work, but it doesn’t:
(get (psm/smart-map env {}) '(:users/list {:filter :active}))
After a bit more digging I found an example in the tests that seem to work for me:
(-> (psm/smart-map env {})
(psm/sm-touch! '[(:users/list {:filter :active})])
:users/list)
Maybe I’m wrong but so far it seems that
(= (p.eql/process query-env query-data)
(->
(psm/smart-map query-env {})
(psm/sm-touch! query-data))) ;=> true
So far I really like that with this feature you can treat everything like maps (and then potentially add optimizations later)