This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-28
Channels
- # announcements (1)
- # aws (1)
- # babashka (41)
- # beginners (21)
- # biff (7)
- # calva (102)
- # cider (8)
- # cljs-dev (1)
- # clojure (8)
- # clojure-bay-area (2)
- # clojure-dev (30)
- # clojure-europe (40)
- # clojure-norway (52)
- # clojure-sweden (9)
- # clojure-uk (5)
- # clojurescript (15)
- # cursive (7)
- # data-science (1)
- # datomic (23)
- # events (1)
- # fulcro (9)
- # humbleui (23)
- # hyperfiddle (46)
- # introduce-yourself (1)
- # jackdaw (2)
- # jobs (2)
- # london-clojurians (1)
- # malli (13)
- # off-topic (8)
- # re-frame (36)
- # remote-jobs (1)
- # shadow-cljs (4)
- # specter (4)
- # squint (1)
- # transit (4)
- # vim (1)
Is it reasonable to merge two queries (for a df/load) for if they have the same ident? For example, component1 queiries [:a :b]
and component2 queries [:b :c]
. I'm not concerned with how to actually merge the query to get [:a :b :c]
- I know the logic I want to use. I'm concerned about the metadata of the query and whether there's something hidden going on I should be concerned about. I normally just create a component with hand-merged query [:a :b :c]
, but I'm starting to get cases where I have 4 or 5 attribute sets that I want to load in various combinations and it feels awkward to write a component for each combination
So technically IF you use the EQL AST and preseve the :component
entry (make sure there is a :component on the metadata that has the correct ident function), then it should be fine as long as the ident function on the component is the same.
I think there are helpers: https://github.com/edn-query-language/eql/blob/main/src/edn_query_language/core.cljc#L369
The problem that you are then going to run into is that the load itself wants a component, not a query; however, you can work around that one by making your own load function wrapper that just triggers the internal load mutation.
If you look at the implementation of df/load!
, you’ll see that it extracts the query from the component. I used to have a load-data
that would allow for an arbitrary query, but since the normalization logic on that wasn’t very clear I decided that this kind of advanced usage would be better to just let you do via direct use of the internal-load!
mutation.
(transact! this [(df/internal-load!
{:source-key :person/all
:query (comp/get-query Person)
:remote :remote})])
should be exactly equivalent to (df/load! this :person/all Person)
Keep us posted!