The route params that @holyjak mentioned is how I’d do it. That is not legacy routing. The parameters passed to the routing instruction are made available to will-enter in all targets. They need not be part of the “path”. The path parameters make them part of the decision logic for routing…passing other data just makes them part of the params.
In general I would discourage using :db/id. You end up with a ton of resolvers all saying “I can resolve that given a :db/id”, which gives no specificity to your system. I would highly encourage you to use things like :session/id
as UUIDs. This also makes you database easily shardable later and make data migration easier.
Technically to-many output should be in vectors, not lists or seqs. Pathom may heal those, but the formal expected data is vectors.
https://github.com/realgenekim/fulcro-rad-demo/blob/gene-experiments/src/datomic/com/example/components/database_queries.clj#L119
Your actual query function f a session returns nil:
perhaps you meant (log/spy :info session)
?
Holy smokes. What a face palm moment! Thanks for catching that, @tony.kay.
I fixed the two return value issues you pointed out in the db queries — specifically, the vector shape of get-all-sessions
and the stupid nil in get-session-by-eid.
But for life of me, I can’t seem to get get-session-by-eid
to be called by the resolvers.
If I understand correctly, pathom looks at elements of the desired :pc/output
, and searches for a set of resolvers to get there…
So, somehow, I must be calling parser
with the wrong input (`db/id`), or the wrong desired output (`session/title`, etc…)
(Sorry, just thinking aloud here…. Checking my changes in, and going to stare at the screen some more! 🙂
…my goal is to get the resolver working via entity-id first, and then get those uuid properties created…
@genekim did you add it to the list of resolvers?
guessing…not 🙂
the resolvers are installed manually. You can make a macro and atom soln if you want, but by default it is a manual install on server.
see all-attributes and all-resolvers
which compose them all from other nses
Oh! Okay, looking at how to get it fixed…. Right now, session-by-eid
is a pc/resolver
, which only shows up in the CLJ portions…
Do I convert it to a defattr
? (Because I’m guessing the CLJS client needs to see it?)
Thanks for your patience and help, @tony.kay!
(You might see from all my commented out code how many permutations I’ve tried… I already see that I made a defattr
version of session-by-eid
… Trying that now. 🙂
@tony.kay Does this look closer to you? https://github.com/realgenekim/fulcro-rad-demo/blob/gene-experiments/src/shared/com/example/model/session.cljc#L103
I’ve fixed the bug in Inspect with network/EQL where quotes were getting lost so that “Send to EQL” was sort of a pain to use. I’m building the chrome store extension now
Version 3.0.3 of Chrome extension submitted for review.
For those that want to install it early: https://github.com/fulcrologic/fulcro-inspect/releases/tag/chrome-3.0.3
https://github.com/fulcrologic/fulcro-inspect/releases/tag/electron-3.0.3
I’m sorry if this is something obvious I’ve missed but I’ve been stuck on this for a few hours: I can’t seem to load initial-state in my sub components (defined with defsc). Eg:
(defsc EntryPanel [_ {:user/keys [name]}]
{:query [:user/name]
:initial-state {:user/name "Aleksander"}
:ident (fn [] [:component/id :entry/panel])
}
(ui/view {:style (tw :w-full :flex-1 :p-5 :align-start :justify-start)}
(comp/fragment
(ui/text {:style (tw :text-sm :mb-1 :text-primary)} "Mon, Nov 17")
(ui/text {:style (tw :text-2xl :mb-2 :text-primary)} (str "Good morning, " (.stringify js/JSON params)))
(ui/text {:style (tw :text-lg :text-primary)} "What did you eat today??")
(ui-new-entry-overlay))))
(def ui-entry-panel (comp/factory EntryPanel))
// In root:
(defsc Root [_ {:root/keys [random]}]
{:query [:root/random]
:initial-state {:root/random "Yo Bro"}}
(ui/safe-area-view
{:style (tw :items-center :px-0 :justify-center
:bg-white :flex-1 :h-full :flex-col)}
(ui/text
random)
(ui-entry-panel {})))
• Nothing shows up in the database in fulcro inspect for EntryPanel (or rather :user/name doesn’t show up)
• It’s not in the parameters I’m printing on the screen either
• :root/random does work exactly as expected
• the initial state dooes show up when I explicitly call (comp/get-initial-state EntryPanel {})
in the replhas to be composed to root @aleksander990
initial state is about the very first animation frame in the entire program, and is a complete graph from root
it is not a constructor
use mutations and loads to join run-time objects into the view graph. Fulcro uses (by default) a complete reified data graph of the view
it is literally View = F(state)
if you want to “hang” a floating root (not connected in data graph) in your UI, you use the multi-root renderer. There’s a demo of that in the workspaces of Fulcro…and I think it’s documented in book. https://github.com/fulcrologic/fulcro/blob/develop/src/workspaces/com/fulcrologic/fulcro/cards/multi_root_cards.cljs
specifically item 2 in https://book.fulcrologic.com/#_adding_initial_state_to_components
Floating roots: https://book.fulcrologic.com/#_using_fulcro_component_classes_in_vanilla_js_detached_subtrees
Arhh, ok. I think it’s startinng to make sense
So basically this:
(defsc Root [_ {:root/keys [entry-panel]}]
{:query [:root/entry-panel]
:initial-state {:root/entry-panel (comp/get-query EntryPanel)}}
(ui/safe-area-view
{:style (tw :items-center :px-0 :justify-center
:bg-white :flex-1 :h-full :flex-col)}
(ui-entry-panel entry-panel)))
common misunderstanding. I need to write a 3 page “things you MUST know” doc 😜
@tony.kay this was really great. Super nice way to understand the basics. I feel like I have a much better grasp on how everything fits together
I just don’t have a whiteboard right now, or I’d do it over…it’s the right thing for beginners
Absolutely. I had a mental disconnect between the view nodes in the graph and the data that's loaded. It makes a lot of sense to explicitly connect the data to views (as opposed to doing a filter on every render over the entirety of the data). I took a bunch of note that I expect will help future team members
And understanding why I need to go through the root to initiate app state makes a lot more sense now as well
no, get-initial-state
not get-query
arhh of course
my bad
you do need to join the query too
and initial-state has magic (it can use query)
i.e. {:root/entry-panel {}}
=== (fn [params] {:root/entry-panel (get-initial-state EntryPanel {})})
just a shorthand, but super handy…also works in to-many rels
{:root/entry-panel [{:id 1} {:id 2} {:id 3}]}
=== `(fn [params] {:root/entry-panel [(get-initial-state EntryPanel {:id 1}) (get-initial-state EntryPanel {:id 2} ...]})`
I’m planning on writing a small internal one for new engineers as I bring them on board. So I hope I’ll be able to give something back to this amazing project you’ve built
Like this?
(defsc Root [_ {:root/keys [entry-panel]}]
{:query [:root/entry-panel]
:initial-state {:root/entry-panel {}}}
(ui/safe-area-view
{:style (tw :items-center :px-0 :justify-center
:bg-white :flex-1 :h-full :flex-col)}
(ui-entry-panel entry-panel)))
It worked when I did it with get-initial-state explicitly but the “short-hand magic” doesn’t seem to
oh
do I then do this down in EntryPanel
(fn [params] {:root/entry-panel (get-initial-state EntryPanel {})})
95% of beginner problems are: didn’t fully grok query/ident/initial-state basics. There’s actually very little to them…it might be helpful to watch this old whiteboard talk I gave on “Untangled”, back when Om Next was still part of the internals. This is probably true for most ppl, I just hate recommending it when it isn’t right for F3, but the GRAPH info and initial state stuff has not changed (though the API and internals are a bit diff): https://www.youtube.com/watch?v=mT4jJHf929Q&list=PLVi9lDx-4C_T_gsmBQ_2gztvk6h_Usw6R&index=8&t=1578s&ab_channel=TonyKay
I really need to redo that video and bring the API and terminology up-to-date…is so very useful I think.
Thank you, by the way. Unblocked and moving forward. This is awesome. And the inspect tool is a game changer