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 {}))So far I really like that with this feature you can treat everything like maps (and then potentially add optimizations later)
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))) ;=> trueyeah, touch is like a preload feature for smart maps
I guess nested data doesn’t make sense with Smart Maps?