Fork me on GitHub
#fulcro
<
2020-05-17
>
roklenarcic19:05:39

Hm if my remote returns {:my.ns/my-key nil} then in fulcro I get :com.fulcrologic.fulcro.algorithms.merge/not-found as value instead of nil… is there any way to return nil values for queried properties?

dvingo20:05:57

I ran into this recently too. I think you can customize the fulcro app to leave them, but if you just want it for one component you can use pre-merge:

(defsc TaskItem [this props]
  {:query [:task/duration :task/description :task/scheduled-at :task/id]
   :ident :task/id
   :pre-merge     (fn [{:keys [data-tree]}]
                    (merge
                      data-tree
                      {:task/duration
                       (merge/nilify-not-found (:task/duration data-tree))
                       :task/scheduled-at
                       (merge/nilify-not-found (:task/scheduled-at data-tree))}))}

roklenarcic20:05:03

hm ok… I see I have a different problem in pre-merge. The load doesn’t get fs/form-config-join in the query, so if my pre-merge returns initial form data, it doesn’t get normalized

roklenarcic22:05:35

that makes pre-merge less useful

dvingo22:05:15

that's one of the uses of pre-merge, to add form config, just merge it into the tree: (fs/add-form-config PersonForm person-tree) http://book.fulcrologic.com/#_initializing_a_tree_of_data

roklenarcic23:05:12

Doesnt work because firm-config is not part of the load query so it does not get normalized into the tree making it throw errors