Fork me on GitHub
#fulcro
<
2019-04-26
>
exit218:04:46

@tony.kay I seem to be running into the issue again after doing a df/load-action where I update my global state via post-mutation and the UI isn’t updating

exit218:04:59

I fixed this elsewhere by doing the same mutation onChange and onBlur

exit218:04:09

any ideas on how to force re-render?

tony.kay18:04:20

The rendering should just be a matter of listing what data changed in your :refresh list

tony.kay18:04:12

I’m pretty sure post mutations also allow a declarative refresh on the mutation itself.

Chris O’Donnell22:04:21

I'm trying to do a bit of ast manipulation for a remote call and am baffled by the result; would love some help. Here's my mutation:

(defmutation set-current-user
  [{::user/keys [id] :as user}]
  (action [{:keys [state]}]
    (let [user-ident [::user/id id]]
      (swap! state #(-> %
                        (assoc-in user-ident user)
                        (assoc-in [:current-user :singleton] user-ident)))))
  (remote [{:keys [ast]}]
    (fp/query->ast `[{(type/insert-user ~{:objects [user]
                                          :on-conflict {:constraint 'user_pkey
                                                        :update-columns '[id email]}})
                      [{::type/returning
                        [::user/id]}]}])))
When I run a transaction with this mutation, I get this error: INTERNAL ERROR: split-mutations was asked to split a tx that contained things other than mutations. [[{(little-gift-list.type/insert-user {:objects [{:little-gift-list.type.user/id #uuid "uuid redacted", :little-gift-list.type.user/email ""}], :on-conflict {:constraint user_pkey, :update-columns [id email]}}) [{:little-gift-list.type/returning [:little-gift-list.type.user/id]}]}]]. The transaction in the error message is wrapped in a vector, which seems to be causing the problem. I'm just not sure why that's happening. Any ideas?

tony.kay23:04:33

@codonnell you want prim/query->ast1

tony.kay23:04:54

a mutation is a node of an ast…`query->ast` returns an AST tree with children

tony.kay23:04:21

also, you might want to leverage returning if you want the result auto-merged

Chris O’Donnell23:04:37

Thanks. 👍 Don't think I need returning here, since I'm already transacting what I need in the local action. The ::type/returning bit is just there to satisfy the schema of the graphql API I'm hitting.

Chris O’Donnell23:04:39

@tony.kay should the example at http://book.fulcrologic.com/#_morphing_mutations be using prim/query->ast1 then?

tony.kay23:04:33

I think so…let me know if that works for you so we’re sure I’m not mis-remembering myself 🙂

tony.kay23:04:41

if so, let me know and I’ll fix the typo

Chris O’Donnell23:04:59

Yeah, it works with prim/query->ast1