Fork me on GitHub

I’m not sure if this is fulcro related or not and i’m quite a beginner but i thought i give it a shot. I set up the leiningen fulcro template to make a few tests and tried to use “sablono” in it. I added sablono to the list of dependencies in project.clj (`[sablono "0.8.1"]`) and require it in root.cljc: [sablono.core :as html :refer-macros [html]]. When i start the server, it can initially render the page with sablono. Every subsequent change or restart of the server yields Unable to resolve symbol: html in this context though. Is there anything missing about the setup of the fulcro template to make the dependency stable?


@fatihict ahh, awesome. That makes sense. Thank you :)


How can I wrap a mutation with another one? Fulcro bootstrap has show-modal and I'd like to have a mutation that basically wraps it and delegates to it.


Can you explain why you want to wrap that mutation?


I want to detect if modal wasn't initialized


basically I want to fill out init data for modal before each show-modal


I could do it as another mutation and list both mutations in the vector


[(prepare-modal) (show-modal)]


but now I have bunch of mutations with similar parameters and theres a lot of parameter duplication


@roklenarcic If I run into that issue I just extract functions from the different mutationsand create a mutation that composes those mutations together calling the extracted functions.


@roklenarcic What Mitchel suggests is also my suggestion (see Reference Guide). Of course, transact! itself accepts a sequence, so you can compose them at the UI layer, or behind the scenes at the mutation layer; however, mutations are intentionally structured to not be “nestable”. Nesting creates a lot of incidental complexity. Writing helper functions that accomplish tasks and using those in your mutations is better.


Any State => State function can easily be composed into a swap! in a mutation (swap! state #(-> % (do-thing-a params) (do-thing-b params) ...)


I guess the only issue is when a mutation comes for a lib


then I can't break it up into a function


But I'll think of something, maybe a function that puts together the mutation vector


I guess that's one way to do it


So, a library should always be written with composition in mind. For Fulcro they should supply both the mutation, and the helper function that works just on state.


But you’re also correct in that nothing prevents you from writing modal-transact! that wraps some tx modification with a call to transact!


or a data xform that works on txes


food for thought: have you considered enabling AST/reads optimizations server-side? This is not something I would need today, but thinking long term, I thought that it might come handy sometime in the future, to be able to optimize DB operations based on the whole query tree. Right now fulcro uses defquery-root as a point where you implement a read of a single key. But sometimes, you have multiple reads of the same type in or some other reads that can be processed in bulk. Like AST has read for number of people in the database and another key requested list of people with an empty filter. The second operation can also supply data for the first read. Just something I was thinking about when reading about these kinds of optimizations being done with GraphQL server-sides.


So, the macros are just wrappers for a multimethod. On the server side the base primitive is the Om query parser (which you can in turn further wrap in whatever you want). Many applications will be fine with the macros and built-in parser, but more complex apps can already leverage the primitives instead in whatever way you want.


See also @wilkerlucio’s work on pathom. He’s done some amazing stuff for building server parsers.


thx I'll look into it


Yeah, he was just demoing something the other day where he has it turning graph queries into REST calls against Spotify REST API.