I’m trying to get the “Index Explorer” page to work, but nothing shows up when I press Load index. • I’ve mirrored the patho.clj parser from Fulcro Native Template • I’ve mirrored the middleware as well • I do get what looks like a succesfull response This is what I see:
I tried the Pathom Viz explorer and it throws the following error:
java.lang.RuntimeException: java.lang.Exception: Not supported: class com.wsscode.pathom.connect$fn__31906
at com.cognitect.transit.impl.WriterFactory$1.write(WriterFactory.java:65)
at cognitect.transit$write.invokeStatic(transit.clj:167)
at cognitect.transit$write.invoke(transit.clj:164)
at com.fulcrologic.fulcro.server.api_middleware$write.invokeStatic(api_middleware.clj:151)
at com.fulcrologic.fulcro.server.api_middleware$write.invoke(api_middleware.clj:148)
at clojure.lang.AFn.applyToHelper(AFn.java:160)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$update_in$up__6853.invoke(core.clj:6185)
at clojure.core$update_in.invokeStatic(core.clj:6186)
at clojure.core$update_in.doInvoke(core.clj:6172)
at clojure.lang.RestFn.invoke(RestFn.java:494)
at com.fulcrologic.fulcro.server.api_middleware$wrap_transit_response$fn__38673.invoke(api_middleware.clj:169)
at ring.middleware.resource$wrap_resource_prefer_resources$fn__39075.invoke(resource.clj:25)
at ring.middleware.content_type$wrap_content_type$fn__38877.invoke(content_type.clj:34)
at org.httpkit.server.HttpHandler.run(RingHandler.java:117)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.Exception: Not supported: class com.wsscode.pathom.connect$fn__31906
at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:194)
at com.cognitect.transit.impl.JsonEmitter.emitMap(JsonEmitter.java:171)
at com.cognitect.transit.impl.AbstractEmitter.emitMap(AbstractEmitter.java:85)
at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:184)
at com.cognitect.transit.impl.JsonEmitter.emitMap(JsonEmitter.java:171)
at com.cognitect.transit.impl.AbstractEmitter.emitMap(AbstractEmitter.java:85)
at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:184)
at com.cognitect.transit.impl.JsonEmitter.emitMap(JsonEmitter.java:171)
at com.cognitect.transit.impl.AbstractEmitter.emitMap(AbstractEmitter.java:85)
at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:184)
at com.cognitect.transit.impl.JsonEmitter.emitMap(JsonEmitter.java:171)
at com.cognitect.transit.impl.AbstractEmitter.emitMap(AbstractEmitter.java:85)
at com.cognitect.transit.impl.AbstractEmitter.marshal(AbstractEmitter.java:184)
at com.cognitect.transit.impl.AbstractEmitter.marshalTop(AbstractEmitter.java:211)
at com.cognitect.transit.impl.JsonEmitter.emit(JsonEmitter.java:41)
at com.cognitect.transit.impl.WriterFactory$1.write(WriterFactory.java:62)
... 20 more
I’m still trying to figure out this issue, but thank you for helping out!
About the default write handler example: What do I need to do with it? Where do I put it?
I don’t have any experience with transit, so I’m still trying to decipher what’s happening.
I copied the ::pc/indexes
output to see if you can see any clues as to which of the functions is the culprit.
In that case I can write logic to dissoc the extra properties per the fulcro example.
I’m surprised i’m hitting this though: I hardly have any resolvers at all
I copied the code from this example first, and lastly the one you linked above: https://blog.wsscode.com/pathom/v2/pathom/2.2.0/connect/exploration.html But where do I put it? In one of my own namespaces, and then I load it? Or should I add it to the parser?
hello, looking at your code I can see :com.wsscode.pathom.connect/resolve #function[com.wsscode.pathom.connect/fn--39871]
, so its trying to send functions over the wire
the write handler needs to go in whatever part of your code you do the Transit encoding
had you tried using the Pathom Viz standalone app? (with the pathom-viz-connector, the setup there should work)
Hmm, it’s starting to make sense. I’m using the standard wrap-transit-response
middleware from fulcro right now
Using this from the Fulcro RAD example worked:
(pc/defresolver index-explorer [{::pc/keys [indexes]} _]
{::pc/input #{:com.wsscode.pathom.viz.index-explorer/id}
::pc/output [:com.wsscode.pathom.viz.index-explorer/index]}
{:com.wsscode.pathom.viz.index-explorer/index
(p/transduce-maps
(remove (comp #{::pc/resolve ::pc/mutate} key))
indexes)})
I’ll try to submit it to the fulcro-template and the fulcro-native-templates so they are up to dateyou need to add the plugin manually
looks like some encoding issue, do you have any nom standard types in your data?
and are you using the native app, or via fulcro inspect?
I’m using the native Fulcro App (and the native Pathom Viz app) When you say, none standard types in my data, do you mean the resolver and mutation definitions?:
(defmutation upsert-entry!
[{:keys [crux-node]}
{:entry/keys [id
text
refs] :as entry}]
{::pc/input #{:entry/id :entry/text :entry/refs}
::pc/output [:entry/id]}
(upsert-entry crux-node entry))
(defresolver entry-resolver
[{:keys [crux-node]} id]
{::pc/input #{:entry/id}
::pc/output [:entry/text]}
(repo/get crux-node id))
These, outside of the index-resolver, are the only ones that are registrered right now
ohhh
could it be #uuid?
good to know! In com.fulcrologic.rad/pathom#parser-args
it looks like the trace-plugin is attempted to be added, but guess we still have to add it at the top level?
hmm… This is all I’m registrering now. And I’m still getting the error:
(pc/defresolver index-explorer [env _]
{::pc/input #{:com.wsscode.pathom.viz.index-explorer/id}
::pc/output [:com.wsscode.pathom.viz.index-explorer/index]}
{:com.wsscode.pathom.viz.index-explorer/index
(get env ::pc/indexes)})
(def all-resolvers [index-explorer])
This is my parser:
(defn build-parser [crux-node]
(let [real-parser
(p/parallel-parser
{::p/mutate pc/mutate-async
::p/fail-fast? true
::p/env {::p/reader [p/map-reader
pc/parallel-reader
pc/open-ident-reader
p/env-placeholder-reader]
::p/process-error process-error
::p/placeholder-prefixes #{">"}}
::p/plugins [(pc/connect-plugin {::pc/register all-resolvers})
(p/env-wrap-plugin (fn [env]
;; Here is where you can dynamically add things to the resolver/mutation
;; environment, like the server config, database connections, etc.
(assoc env
:crux-node crux-node
:config *config*)))
(preprocess-parser-plugin log-requests)
p/error-handler-plugin
(p/post-process-parser-plugin p/raise-errors)
p/request-cache-plugin
(p/post-process-parser-plugin p/elide-not-found)
p/trace-plugin]})
;; NOTE: Add -Dtrace to the server JVM to enable Fulcro Inspect query performance traces to the network tab.
;; Understand that this makes the network responses much larger and should not be used in production.
trace? (not (nil? (System/getProperty "trace")))]
(fn wrapped-parser [env tx]
(async/<!! (real-parser env (if trace?
(conj tx :com.wsscode.pathom/trace)
tx))))))
there is an annoying issue with sending the index in pathom 2, that it tries to send the resolver and mutations functions with the index, and that breaks encoding, it shouldnt because we do have a default handler, but this issue seems to keep getting back
one way around it is to manually remove this fns from those index before sending (do it at the resolver that exposes the indexes)
not sure if thats the problem you are seeing, but I think is worth trying
Is that’s what’s done here? (from the Fulcro example):
(pc/defresolver index-explorer [env _]
{::pc/input #{:com.wsscode.pathom.viz.index-explorer/id}
::pc/output [:com.wsscode.pathom.viz.index-explorer/index]}
{:com.wsscode.pathom.viz.index-explorer/index
(-> (get env ::pc/indexes)
(update ::pc/index-resolvers #(into [] (map (fn [[k v]] [k (dissoc v ::pc/resolve)])) %))
(update ::pc/index-mutations #(into [] (map (fn [[k v]] [k (dissoc v ::pc/mutate)])) %)))})
(still not working if that’s the case)
yeah , should be it, from the error stack seems like some fn is trying to get encoded
a better fix is try to fix the default encoder
you can try bumping transit, it had a but around default write handler in some versions
here is a full configuration example to get default write handler https://github.com/wilkerlucio/pathom-viz/blob/master/src/core/com/wsscode/pathom/viz/transit.cljc
Hi there, I have a console error ERROR [com.fulcrologic.fulcro.routing.dynamic-routing:133] - route-immediate was invoked with the ident [:component/id :main] which doesn't seem to match the ident of the wrapping component (class Main , ident [ null ...])
which I'm not sure how to fix it. Here's what I have:
(defn ^:export init []
(log/merge-config! {:output-fn prefix-output-fn
:appenders {:console (console-appender)}})
(log/info "Starting App")
;; Avoid startup async timing issues by pre-initializing things before mount
(app/set-root! app Root {:initialize-state? true})
(dr/initialize! app)
(app/mount! app Root "app" {:initialize-state? false})
(dr/change-route! app (dr/path-to Main)))
;; Root
(defrouter RootRouter [_ {:keys [current-state]}]
{:router-targets [Login Main]}
(case current-state
:pending (dom/div "Loading...")
:failed (dom/div "Loading seems to have failed. Try another route.")
(dom/div "Unknown route")))
(def ui-root-router (comp/factory RootRouter))
(defsc Root [this {:root/keys [router]}]
{:query [{:root/router (comp/get-query RootRouter)}]
:initial-state {:root/router {}}}
(dom/div
(ui-button {:onClick #(dr/change-route this ["main"])} "Go to main")
(ui-button {:onClick #(dr/change-route this ["login"])} "Go to login")
(ui-root-router router)))
;; Main
(defsc Main
[_ _]
{:indent [:component/id :main]
:route-segment ["main"]
:query [:main]
:initial-state {:main {}}
:will-enter (fn [_ _] (route-immediate [:component/id :main]))}
(dom/h1 "Main!"))
(def ui-main (comp/factory Main))
It works fine(?) but that console error is thrown every time I change-route!
. Would appreciate any help. Thanks in advance.:ident (fn [] [:component/id :main])
if you supply a vector (like you did) it means (fn [] [:component/id (:main props)])
and if you supply just a keyword :ident :k
it means (fn [] [:k (:k props)])
see book
and docstring
Ah I see. Thanks for pointing me in the right direction 🙂
Also I just realised something profoundly silly: I've been reading and using indent
the entire time instead of ident
.
That is some massive 🤦 right there
ah yes, and if you do that you don’t get normalization at all 😜
haha I've looked at fulcro code for so long and it has never occurred to me once that I've been reading it wrong since the beginning
😅
and... changing to the right word fixes all the console errors
yep 🤦
hi @tony.kay it is probably small thing but wanted to let you know: when i searched fulcrologic using duckduckgo, it has indexed and shows http://www.fulcrologic.com/home at the top which return 404 resulting in not opening the page from the search results. Trying it manually did redirect to home page but "opening in new tab" or copy pasting it returns 404 as well.