Fork me on GitHub

Following the instructions of the fulcro rad template at I ran the script but it leaves behind a ton of files that end in -e (for example application.cljs-e. Is this expected?


ah looking at the script, sed’s -e option is specified after -i and (on a Mac at least) this makes it use -e as the backup file extension


looking at the man page, I think we want to change it to sed -i '' -e "s/com.example/$1/g" $f instead. Guess I can open a PR for that 🙂

❤️ 1
Jakub Holý (HolyJak)17:04:31

Yes, the differences between mac and Linux versions of common programs have bitten me multiple times 😔

👍 1

I’ve got a problem with tempids that I don’t know how to solve. The issue basically is that I cannot map tempids in mutation parameters to their new values. The default-result-action! will run after each mutation in transaction and it will call rewrite-tempids! which will take mutation’s tempid->real-id map and change tempids to resolved IDs in TX queue (changing mutations that haven’t been sent to remotes yet) and changing state. That’s all well and good, but there’s one place this is missing. The mutation’s parameters. You can see example here in this patch: This is the save-as-form mutation, and I had to apply this fix, because ok-action closes over root-ident which might contain tempid. It will get mapped to real ID server-side, but I had to manually fix the closed over values, so they contain new ID instead of tempid. Now I have a more complex example, a transaction with 2 mutations:

(let [id (tempid/tempid)
        invoice (merge {::m.invoice/id id} some-val]
    (comp/transact! component [(form/save-as-form {:root-ident (comp/get-ident InvoiceForm invoice) :entity invoice})
                               (add-invoice-to-list {:id id})]))
Both mutations take an ident with tempid with it and both close over it. save-as-form saves it and maps tempid to a new ID. But the second mutation, which adds the ident to a list of invoices somewhere will always insert the old value, ident with tempid. That transaction also has no access to tempid->real-id mapping that happened in save-as-form so I have no way of fixing that temp ID. So I am at a loss of how to carry temp-id->real-id information from the first (inserting) mutation to other mutations in tx that also operate with same temporary ident.


OK, I have an open issue on this as an unverified bug. I have not had time to make a minimal repro case and look into it. . Are you plugging any custom stuff into the internals of Fulcro? Tx processing? Changing default mutation handler? Changing load mutation?


In the case above, is add-invoice-to-list a local-only mutation? If so, it should have applied before the return value (because optimistic stuff runs immediately). If it is remote, then the values in the params on the remote should have been rewritten for you. Did you look at the network logs in this case?


Oh…ok…I think I see what you’re saying. BOTH mutations are remote, but the remapping happened for the first one, the network request for the second one was fine, but no remapping map was available in the remote result handler of the second? I kind of need clarification there: as in, the code definition in Fulcro for the second mutation.


I found a typo that might be the culprit. Try 3.5.19-SNAPSHOT (commit 16f1ad6f63864454f0cb43702fc4cbcdb7e04fbb)


You should not have to be doing any manual remappings on these.


Hm, so I see what you mean, if the mutation 2 in transaction is local only then the temp ID will get replaced in app state since it runs before the remote action of mutation 1. But what if transaction is pessimistic? And if mutation 2 is remote then it will get replaced in the remote queue? That logic still misses the ok-action, it’s why save-as-form needed that patch, it used the old ident values.


And I tested it just now… the second mutation remote part doesn’t get its parameter tempid updated


So this is quite broken


Fulcro inspect shows that both mutations are sent to remote at the same time, so of course the resolver for the second one still gets tempid in parameter


Right, actually that can't be any other way. If you send one transaction then you are responsible on the server to make it make sense. If you send 2 transactions then it will work fine


Fulcro does no server side logic because it has no idea what you back end actually is


It doesn't even know if you're using pathom or some hand written thing


Ok so the solution is to use a single mutation then or multiple transactions. But how do I reuse/extend existing mutations? Basically I have save-as-form mutation that does most of what I want, but I also want to add the item to some list of entities. I’ve added a mutation to tx for this purpose but as seen, the tempid logic doesn’t link up. What's the expected solution for this user story?


Save as form has a server side helper that you can compose there.


But it also has client side logic in remote section, so I have to copy paste that. Seems to be a gap there in capability, on the client side it’s not possible to augment ok-action of a mutation to queue another tx without changing the code of the mutation itself. I cannot specify “if this mutation finishes successfully, do this other mutation” at the transact call site. ok-action is hardcoded in the first mutation. This very much limits composability of simple mutations. Back to replacing tempids in queues. I’ve tried to use pessimistic tx and it sent each of these 2 mutations to backend separately, but the second one still didn’t have tempid replaced with the result of the first one. So that tempid replacement in tx queues doesn’t seem to be working.


Did you use the SNAPSHOT version of Fulcro I mentioned? They should get rewritten if you’ve used two transactions. I don’t think 2 transacts get auto-combined in the current logic…did that turn into 2 network requests?


The two separate requests is the ONLY way that Fulcro can solve this for you


Might be better to ask this in the #cursive channel, but I have warnings all over my IDE for defstate and things that involve it. I’ve seen in the fulcro videos where Tony Kay says to map it to a previous version of fulcro to get it to work, but I don’t have anything like that in my options for the “Specify…” context menu. So then I tried vscode and calva, but it only lets you run 1 REPL by default unless you set up multiple workspaces which I don’t really want to do. So, my question is, going from a fresh IntelliJ Ultimate and a paid version of Cursive, how do I get all the Fulcro macros to resolve correctly?


CLick on the macro name (e.g. defstate) and press CMD-SHIFT-A and type “resolve as”. Pick def. For defsc pick defn, etc.


Some things have built-in support in Cursive, and everything else you have to tell it what the macro in question is “acting like”


There is a problem with recent versions of cursive where it will forget the "resolve as" settings. The work around us to resolve as None and then resolve as to the appropriate definition

👍 2

Try the latest EAP. There was a problem with new ns parser. Seems fixed there

👍 2

awesome. thanks for the help


i have the latest EAP 🙂


After going through each file, here’s what I came up with for the “resolve as” settings (had to export to XML to get it in a text-based format):

  <item key="com.fulcrologic.fulcro.routing.dynamic-routing/defrouter" resolves-as="clojure.core/defn" />
  <item key="com.fulcrologic.guardrails.core/>defn" resolves-as="clojure.core/defn" />
  <item key="com.fulcrologic.rad.attributes/defattr" resolves-as="clojure.core/def" />
  <item key="com.fulcrologic.rad.blob/defblobattr" resolves-as="clojure.core/def" />
  <item key="com.fulcrologic.rad.form/defsc-form" resolves-as="clojure.core/defn" />
  <item key="" resolves-as="clojure.core/defn" />
  <item key="com.wsscode.pathom.connect/defresolver" resolves-as="clojure.core/defn" />
  <item key="mount.core/defstate" resolves-as="clojure.core/def" />
  <item key="" resolves-as="clojure.core/do" />
  <item key="taoensso.encore/if-let" resolves-as="clojure.core/if-let" />
The definition was a tip from a cursive github issue.

👍 2

Thanks, this thread was very useful.

👍 1

If it helps, I’m starting from a cloned repo (hence my comments earlier today about sed )