Fork me on GitHub

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?

Markus Hain10:11:25

You could implement hash-based routing. Anything that appears after # in the URL is ignored by the server. becomes 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.


You could also set your “error” page to have the content of index.html


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


it’s not a terribly lot of code…this is why the system is so pluggable


That ns uses low-level pushState etc, and just ignores libs like pushy…


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 now


Ah, 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?

Jakub Holý (HolyJak)17:11:51

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


Right, but I thought we were adding :tempids to the query on client side

Piotr Roterski17:11:44

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."
  (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


the pathom 2 error key isn’t necessary here


but the error story isn’t perfect…there is never a perfect story there


ok, so could you try git sha 3135c5c157d1a15596951ac3bad734f32d07e538 on fulcro-rad dependency and see if that fixes it?


that should not break the main branch either


pushed as 1.1.0-RC8-SNAPSHOT as well

Piotr Roterski17:11:52

it did solve it for me, :tempids was added to the query on client side


Sorry I was afk for a bit, I'll test it in my app now!

Jakub Holý (HolyJak)18:11:35

We considered adding tempids in Fulcro but using the pathom plugin turned out to be a simpler solution I believe


probably makes sense to just use this basic GEQL handler in general in Fulcro


Okay that has fixed it! Now back to my own bugs 🙃