This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-15
Channels
- # announcements (1)
- # beginners (101)
- # boot (13)
- # cider (38)
- # cljdoc (10)
- # cljs-dev (37)
- # cljsrn (6)
- # clojure (74)
- # clojure-dev (8)
- # clojure-europe (3)
- # clojure-italy (36)
- # clojure-losangeles (2)
- # clojure-nl (5)
- # clojure-spec (15)
- # clojure-uk (49)
- # clojuredesign-podcast (2)
- # clojurescript (52)
- # cursive (6)
- # datomic (19)
- # fulcro (35)
- # graalvm (16)
- # graphql (4)
- # kaocha (1)
- # leiningen (26)
- # luminus (3)
- # re-frame (10)
- # reagent (14)
- # ring-swagger (37)
- # rum (2)
- # schema (4)
- # shadow-cljs (148)
- # spacemacs (13)
- # specter (1)
- # sql (46)
- # tools-deps (3)
- # vim (4)
This feels like it should be a really silly, obvious FAQ. So I apologize if it is. Is there a recent example of using fulcro with a datomic back-end? All my searches turn up results about a) parsing queries into graphql or b) the deprecated fulcro-datomic library (BTW: thank you so much for picking up where Om Next left off!)
@jimrthy We use Pathom to handle all our backend mutations and queries. This abstracts away whether we're hitting Datomic, HTTP, or some other data store. When handling the request, a middleware adds to the pathom env {:db-ref (atom (d/db datomic-conn))}
. Any pathom resolver can access this db to get a consistent read and pull out any data (could be a simple d/pull or something more complicated). We store it as an atom (and not just a value), because if there is a mutation, the mutation will d/transact
and reset!
the db-ref
to the new value. This let's us guarantee read-after-write semantics for a pathom mutation+query. In practice, we separate resolvers that do joins (ala d/q
to find entity ids) and resolvers that just fetch attributes (ala d/pull
on existing entity ids). All resolvers whitelist attributes returned and check permissions of current-user.
@jimrthy I am actually using fulcro with datomic but I haven't find many authorative examples/utility libs either, but I didn't search too much so if there is one I'd like to know too. However the fulcro3-template uses datascript (= datomic-ish) in the back-end: https://github.com/fulcrologic/fulcro3-template/blob/master/src/main/app/model/account.clj Note that nowadays fulcro (fulcro3 anyway..) leaves the back-end code to pathom.
@jimrthy You can follow Fulcro/other examples that exist for creating your own web server (so not the 'easy' server). Bear in mind that the defquery-root
, defquery-entity
and defmutation
server macros are not coming across to Fulcro 3, and so now the Fulcro server will be a typical Clojure web server with altered middleware. Here run-query
is your own function and wrap-api
comes from the require: [com.fulcrologic.fulcro.server.api-middleware :as fmw :refer [not-found-handler wrap-api]]
.
You can then println
inside run-query
, and use the data structure you see there to query Datomic. i.e. run-query
will be returning the result map that your Fulcro browser app has requested.
Hello everyone, I was wondering whether anyone could point me to a reasonably sized fulcro project on Github? I have tried using a few keywords but perhaps some open projects have been shared in the channel earlier.
hello, Fulcro Inspect is a good one to look
altough the code is a bit old, has a descent scale
Yup, it is. I was wondering if there are any plans for porting it to Firefox? The FF dev edition is quite decent as well and FF also changed their web extensions mechanism recently.
@U066U8JQJ, thanks for the help!
just no time to support, but would love to have, an old idea is also to have an Electron client, this way you can use on any environment (not just browsers, could be used for React Native for example)
Yeah, that sounds cool! I'll be going over the repo soon 🙂
has anyone here ever seen or looked into making a db->tree-like macro that takes a compile-time query and produces an optimized db->tree function?
that wouldn''t work well, queries are dynamic and change all the time, also you have to re-process everything when data changes, so it can't be computed ahead of time. makes sense?
what changes your queries? In apps I work on we use stuff like set-query very rarely
depend on the usage, you can for example use :update-query
when you trigger a fetch/load
, there you can update as query freely, another helpers like :focus
and :without
also do query manipulation. but really the point is more about you need the data, reading eql doens't take much time, what could be optimized here is the convertion between EQL -> AST, that can be more easily cached
ahh ok, I suppose fulcro modifies the queries more than expected. I would have asked this in #om but its fairly quiet in there
it is roughly 6x faster to do query processing in F3 than 2. The react overhead is way more than the query processing in most cases.
thanks for the insights, checking out this f3 implementation
another chunk was adding time to the props as a post-step instead of during parsing (that is part of rendering optimization to know the time of the different bits of props).
then the reimplementation sped up the core db->tree as well. So, overall the total overhead in processing the client UI query is dramatically less
I've been following the fulcro3 tutorial, and section 3.6.2 (http://book.fulcrologic.com/fulcro3/#_step_1the_initial_state) it has an example of pulling the initial state from the repl. Question is which repl? I'm trying in both the shadow-cljs dashboard repl in the browser and the one created in Cursive, but I keep getting
(com.fulcrologic.fulcro.components/get-initial-state app.ui.root/Root {})
Syntax error (ClassNotFoundException) compiling at (REPL:1:1).
app.ui.root
is the cursive repl a CLJS repl?
you need a browser connected repl, provided by shadow-cljs
and maybe you need to load namespace you’re in?
I tried using a terminal from within Cursive with npx shadow-cljs cljs-repl main
, and it worked fine. F5 in your Chrome browser if your app is not yet running.
The various clj and cljs repls I still find a bit confusing