This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-15
Channels
- # announcements (20)
- # babashka (281)
- # beginners (13)
- # biff (8)
- # calva (20)
- # cider (5)
- # clj-commons (1)
- # clojure (46)
- # clojure-boston (1)
- # clojure-europe (6)
- # clojure-losangeles (24)
- # clojuredesign-podcast (3)
- # clojurescript (12)
- # datomic (1)
- # events (1)
- # fulcro (12)
- # guix (2)
- # honeysql (1)
- # integrant (1)
- # introduce-yourself (1)
- # rdf (16)
- # reagent (3)
- # reitit (14)
- # releases (3)
- # sci (28)
- # shadow-cljs (122)
- # specter (1)
- # tools-deps (10)
- # xtdb (6)
Hi everyone, in Fulcro, what's the best way to find which backend resolvers are used when querying fields for an frontend component?
More of a back-end/pathom question. In pathom 2 you can add in a plugin like this:
(defn profile-plugin
"Create a profiling plugin for pathom that records the times for resolver/mutation calls. Entries in the stats
will start with `q:` for query resolution and `m:` when it is a mutation."
([] (profile-plugin :pathom))
([group-id]
{::p/wrap-read
(fn profile-plugin-wrap-read [reader]
(fn profile-plugin-wrap-read-internal [env]
(let [k (p/key-dispatch env)]
(p {:id (str "q: " k)}
(reader env)))))
::p/wrap-parser
(fn profile-plugin-wrap-parser [parser]
(fn profile-plugin-wrap-parser-internal [env tx]
(profile {:id group-id}
(parser env tx))))
::p/wrap-mutate
(fn profile-plugin-wrap-mutate [mutate]
(fn profile-plugin-wrap-mutate-internal
[env k params]
(let [out (mutate env k params)]
(cond-> out
(:action out)
(update :action
(fn [action]
(fn []
(p {:id (str "m: " k)}
(action)))))))))}))
with requires:
[com.wsscode.pathom.core :as p]
[taoensso.tufte :as tufte :refer [p profile]]
Then see tufte documentation for getting the collected statsYou can also wrap the body of each actual resolver with tufte/p
to get real performance of a resolver call..sometimes wrap-resolve can do the res without actually calling your code. So, I’ve also written macros to wrap resolver body automatically. That’s actually a better way to get real numbers.
If you just want timings, then Pathom itself also has visualization tools that can be used from front-end.
I was trying to run todomvc (https://github.com/fulcrologic/fulcro/tree/develop/src/todomvc/fulcro_todomvc).
But when I tried to enter a task, there was a pop window saying that "failed to add item to server"
My running procedure is listed below:
• git clone the fulcro project
• npm install at the root of the fulcro project
• npx shadow-cljs server
like fulcro book said
• go to http://localhost:9630/builds to "watch" todomvc
• go to http://localhost:9002/todo.html
Are there any mistakes made? It looks like a remote server problem. How could I fix this?
Thanks in advance 🙏
My terminal had these output https://www.codepile.net/pile/RBwEX1q7
A stupid question, do you run both shadow-cljs and the backend? I use a clone of the TODO MVC in https://github.com/holyjak/fulcro-intro-wshop, check the instructions there
I didn't. 😅 Follow your instruction I am able to run the example successfully. Thanks a lot!
I want to have a follow-up question: In this picture, shadow-cljs has a http server on the port 9002. And the server.clj also have a http server on port 8080. What's the difference. • http://localhost:8080/todo.html => this works • http://localhost:9002/todo.html => this only has front-end, Entering tasks will cause the problem I mention before
Well, that is simple. 8080 is served by the backend so it can also handle backend requests. 9002 only runs the frontend (shadow does that for you as a developer convenience) so any request to the backend will fail b/c there is no backend on that port. (Notice that backend requests go to <same url>/api )