pathom

2023-08-17T11:33:00.191359Z

Is it possible to have resolvers return smart-maps?

2023-08-17T11:33:41.248969Z

I tried, but what I get back is normal maps and I can’t invoke new lookups

2023-08-17T11:34:29.168189Z

This idea might not be a good idea performance wise, but I was thinking it could be nice for expressiveness and optimise later

wilkerlucio 2023-08-17T13:25:37.778059Z

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

nivekuil 2023-08-17T14:01:45.262049Z

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

2023-08-17T14:28:24.354869Z

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.

2023-08-17T14:28:55.011539Z

Anyway, thanks for the feedback. I guess i’m trying something weird. Will experiment a bit more

2023-08-17T16:23:11.808189Z

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 {}))

✔️ 1
➕ 1
2023-08-18T09:39:07.818399Z

So far I really like that with this feature you can treat everything like maps (and then potentially add optimizations later)

2023-08-17T16:27:09.955659Z

In analogy to the resolver I thought maybe this could work, but it doesn’t:

(get (psm/smart-map env {}) '(:users/list {:filter :active}))

2023-08-17T16:50:09.848259Z

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)

2023-08-17T18:19:51.901729Z

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

wilkerlucio 2023-08-17T18:29:03.214859Z

yeah, touch is like a preload feature for smart maps

👌 1
Joel 2023-08-18T03:15:11.239929Z

I guess nested data doesn’t make sense with Smart Maps?