Small Q: is it possible to pass an :update-query to a mutation join returning component?
Apologies for being a bit too vague there. It was indeed about morphing the query for the mutation join, adding extra parameters in keys a bit deeper into the query tree, analogous to what df/load! allows with the :update-query option. A variation on the m/returning fn would indeed be a good option, I'll have a try at that.
I’m not opposed to adding the update-query parameter to the options of m/returning.
But my guess is your specific use-case might be better served by something more project specific anyway.
I don’t understand your question. Are you asking if you can cause a mutation join to emit the “current dynamic query” from a live component that has a dynamically modified query?
The (m/returning) primitive does exactly that.
or do you mean you want to morph the outgoing query in an arbitrary way?
This is the definition of returning:
(defn returning
"Indicate the the remote operation will return a value of the given component type.
`env` - The env of the mutation
`class` - A component class that represents the return type. You may supply a fully-qualified symbol instead of the
actual class, and this method will look up the class for you (useful to avoid circular references).
`opts` (optional):
- `query-params` - Optional parameters to add to the generated query
Returns an update `env`, and is a valid return value from mutation remote sections."
([env class]
(returning env class nil))
([env class {:keys [query-params]
:as opts}]
(let [class (rc/registry-key->class class)]
(let [{:keys [state ast]} env
{:keys [key params query]} ast
component-query (rc/get-query class @state)
updated-query (cond-> (eql/query->ast component-query)
query-params (update-in [:children 0] assoc :params query-params)
:then (eql/ast->query)
query (vary-meta #(merge (meta query) %)))]
(assoc env :ast (eql/query->ast1 [{(list key params) updated-query}]))))))
Roll your own. The helper is just mucking with the AST of the EQL…so yes, you can do what you want.