This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-30
Channels
- # adventofcode (95)
- # announcements (17)
- # babashka (28)
- # beginners (107)
- # calva (34)
- # clj-kondo (7)
- # cljs-dev (20)
- # cljsrn (1)
- # clojure (95)
- # clojure-europe (41)
- # clojure-italy (3)
- # clojure-nl (5)
- # clojure-spec (7)
- # clojure-uk (4)
- # clojurescript (77)
- # cursive (7)
- # data-science (1)
- # datalog (4)
- # datomic (12)
- # events (3)
- # fulcro (32)
- # graalvm (2)
- # hugsql (19)
- # introduce-yourself (4)
- # jobs (2)
- # lsp (20)
- # membrane-term (19)
- # numerical-computing (1)
- # off-topic (8)
- # pathom (3)
- # polylith (17)
- # portal (42)
- # re-frame (7)
- # reagent (32)
- # remote-jobs (1)
- # shadow-cljs (86)
- # spacemacs (3)
- # tools-deps (52)
- # uncomplicate (1)
- # xtdb (23)
I am trying to release a client-only fulcro app, and the main problem I’m having is that routing changes browser URL and then hitting refresh doesn’t work (because the static content serving server doesn’t know what to do with that URL and to serve index.html in all cases). Is there some way around it?
You could implement hash-based routing. Anything that appears after # in the URL is ignored by the server. http://my-app.com/#/user/3 becomes http://my-app.com/ on the server and then the route can be applied on the client. You only need to change the two functions that parse and create the URL.
Can't find any info on how to set up such a page, @U0CKQ19AQ. Little more info, please?
You have to make the serving server of your content server YOUR index.html for routes that are not found.
Client-only, so using shadow's basic server. I guess I'll deal with this when I get to the server part. Heads up for anybody looking to implement hash-based routing – the library pushy doesn't support hash-based urls.
@U0CKQ19AQ I am hosting the compiled page as index.html + main.js on github pages, so I cannot (I think) really do that
then you also cannot use path based routing, and will have to write a hash-based thing for yourself
ah ok
E.g. here’s the RAD HTML5 routing implementation: https://github.com/fulcrologic/fulcro-rad/blob/develop/src/main/com/fulcrologic/rad/routing/html5_history.cljc Are you using RAD?
this is really the crux: https://github.com/fulcrologic/fulcro-rad/blob/develop/src/main/com/fulcrologic/rad/routing/html5_history.cljc#L69
Sanity check please: I think I found a bug, that must have something todo with the pathom3 integration.
You can replicate this in the fulcro-rad-demo on the pathom 3 branch.
In the rad-demo go to Inventory->New
and create a new Item. After saving the url should be rewritten to edit/<some-uuid>
,
instead it get's rewritten to edit/#fulcro/tempid["6617036a-5fd5-4864-868c-73a72aa8ee95"]
and the state machine locks up in what seems to be an undefined state.
I don't see an error in the server logs right now besides the one in the middle here:
I 2021-11-30T15:28:17.036Z _rad.database-adapters.datomic:-367 - Running [:item/name {:item/category [:category/id]} :item/description :item/price :item/in-stock] on entities with :item/id : [[:item/id #uuid "ac1d66fb-bcff-4705-ae5a-6f3fcf4f9419"]]
E 2021-11-30T15:28:17.038Z _rad.pathom3:- 31 - EQL query for :com.wsscode.pathom.core/errors cannot be resolved. Is it spelled correctly? Pathom error: {:com.wsscode.pathom3.error/cause :com.wsscode.pathom3.error/attribute-unreachable}
I 2021-11-30T15:28:17.038Z _rad.pathom-common:- 28 - Response: {com.fulcrologic.rad.form/save-form {:item/id #uuid "ac1d66fb-bcff-4705-ae5a-6f3fcf4f9419", :item/name "asd", :item/category {:category/id #uuid "ffffffff-ffff-ffff-ffff-000000001003"}}}
I'm trying to find the correct spot to debug this nowAh, yes…someone mentioned (@UHA0AQZ2M?) that the tempids were not getting returned. I had not had a chance to look at it. Did you fix that with your xtdb stuff Piotr?
I guess you either need to add :tempids to the query manually on the Fulcro side using global- eql-transform or replicate the pathom2 plugin that did that on the P. side
not yet, but I got a https://clojurians.slack.com/archives/C87NB2CFN/p1638217290220800?thread_ts=1638126453.214800&cid=C87NB2CFN on pathom part and I could try fixing it later today
rad.pathom2 used pathom2's :com.wsscode.pathom.connect/mutation-join-globals
attribute but maybe it shouldn’t be globally added to all queries - it seems to be only relevant for save-form mutations
should be this on app side:
(defn global-eql-transform
"Returns an EQL transform that removes `(pred k)` keywords from network requests."
[pred]
(fn [ast]
(let [mutation? (symbol? (:dispatch-key ast))
has-children? (seq (:children ast))]
(cond-> (-> ast
(rad-app/elide-ast-nodes pred)
(update :children conj (eql/expr->ast :com.wsscode.pathom.core/errors)))
(and mutation? (not has-children?)) (update :children conj (eql/expr->ast '*))
mutation? (update :children conj (eql/expr->ast :tempids))))))
to get the correct behavior we need *
as the mutation join if there isn’t one, and force include :tempids if there is
ok, so could you try git sha 3135c5c157d1a15596951ac3bad734f32d07e538 on fulcro-rad dependency and see if that fixes it?
it did solve it for me, :tempids
was added to the query on client side
We considered adding tempids in Fulcro but using the pathom plugin turned out to be a simpler solution I believe