hehe, having some fun with this, prob gonna do a post in the next week 🙂
It's no different. You still create a Fulcro app for using transact
everything is CLJC
so, if you're doing server-side rendering you can start the app headless, run your mutations, and then pull the state from the atom and send that to the client.
If you mean you want to run the client mutation on the server for something else, what is that something else? Or do you mean you need to run a server-side mutation? If that's what you mean, and you're using pathom, you call the parser instead of transact.
good to hear. Let me know any other thought
@tony.kay My question is probably a bit more elementary. I cannot figure out in Fulcro Template, if I try to run components/transact!
what do I use for the app-or-comp
argument as in the line below? https://github.com/fulcrologic/fulcro/blob/5277886b86ef3502342e9e1ff07dbedfe3793bdc/src/main/com/fulcrologic/fulcro/components.cljc#L792
A Fulcro app
you need to be more explicit about why you want to call transact on the server side
If you mean you just want to cause that mutation to run AS IF you'd called it on the client, then you need to invoke your middleware parser on the transaction
If that's what you want, then after starting the server, you can run:
For development in REPL, I would like to develop a server side mutation, make sure the output is what I expect it to be. So if I try to run a mutation in Fulcro Template on the client side, I do this:
(comp/transact! SPA [(login {:username "john" :password "mysecurepassword"})]))
On the client side, the app-ro-comp
is defined here: https://github.com/fulcrologic/fulcro-template/blob/a169b0ab50c0b390ac5efe24e307d371ec2f2bd3/src/main/app/application.cljs#L13
It is the SPA variable, What do I use on the server side instead of SPA?(app.server-components.pathom/parser {} '[(app.model.session/login {...})])
transact!
does not run the server side stuff. The middleware receives it as a EDN and runs the parser
so, calling the parser is probably what you're wanting?
if so, define your own dev helper that just runs some transaction on the parser like above
Ahh, OK, yes I think I understand. Will try it.
The map, of course, is the env
that resolvers/mutations on server side get as env
server mutations and resolvers in pathom 2.x are just maps, and one of the keys is the actual resolver fn, which you could also just directly call
What I usually do is define the functionality in a regular function that can be easily unit tested, and then call that function from the resolver. That way you have an easier way to work with it outside of parsing.
OK, this helps, I was wondering why the functionality was broken out, specially in Fulcro RAD Demo, seemed like extra files, but now I understand.