Fork me on GitHub
#fulcro
<
2024-02-01
>
Rambabu Patina12:02:37

Hi, I have a fulcro app which needs to call a remote call on component load. We have a component which already working. I tool the same code and implementing new one. But on component loading it is not making a remote call. Not sure what I was missing?

(app/fulcro-app
        (i18n-utils/with-i18n
          {:shared {:licensed? licensed?}
           :client-did-mount
             (fn [app]
               (df/load! app :>/global-config global-number/GlobalConfig {:post-mutation `global-number/data-loaded!}))
           :remotes {:remote (remote/remote remote/global-env)}}))

Rambabu Patina12:02:31

For remote calls we use pathom3 library and the code reference,

(def global-properties
  [::numbering-config/enabled?])
...
(pco/defresolver
  global-configuration
  []
  {::pco/output global-properties}
  (p/let [
{:keys [value]} (get-global-config-property)]
    (->
     (global-config/from :global-config value))))

(pco/defmutation set-global-configuration [config]
  {::pco/op-name 'app.global-config/set
   ::pco/output global-properties}
  (p/let [{:keys [error value]} (set-global-config-property (global-config/to :global-config (:settings config)))]
    (if error
      (throw (ex-info "Failed to save global configuration" {:config (:settings config)} error))
      (->
        (global-config/from :global-config value)))))
....
(def global-env (pci/register [global-configuration set-global-configuration]))

Rambabu Patina12:02:14

Your help will be greatly appreciated. Thanks

Rambabu Patina04:02:27

Thanks @U0522TWDA for your valuable suggestion. I did debug and fixed it.

Brett14:02:48

Hey, any idea why my call to merge! works regardless of the query I use ? I'm using it inside a mutation to sort a list of things and I merge! with the updated tree that is basically at the root. Everything works, my db is updated and all the links are working in the inspect tools, however I noticed that it doesn't care what query I use.

tony.kay19:02:12

The query is only used for normalization. If you use an incorrect query, then the data will still merge with the database, but it will not be normalized. This is a supported mode of operation, as it is sometimes useful in cases where the data does not get updated but needs to be fast

👍 1