Fork me on GitHub
#untangled
<
2016-07-11
>
curtosis01:07:57

do components have to have an ident to be able to launch queries (via df/load-field)?

currentoor03:07:12

also, it kind of makes sense right? a query needs to map to some root in the app state

curtosis04:07:19

hmm... yeah

curtosis04:07:42

I got mine working, it's weird with the tab-switching setup

curtosis04:07:12

I gave my mappings tab an ident of [:ui :mappings]; it doesn't have one because the tab switcher provides ident. When the data comes back, instead of being under {:mappings-tab {1 {:mappings { ... }}} (I haven't updated the tab idents to the new style yet) it naturally ends up at {:ui {:mappings {:mappings { ... }}}}.

curtosis04:07:32

And yes, there's an extra nesting there I'll have to sort out. 😛

curtosis04:07:48

I also feel like I'm doing more work than I ought to in the server read to map it to the datomic query. But for the moment it's working, so it's progress.

curtosis15:07:24

I think I'm still not clear on where data for a tab should be in app-state. The cookbook example uses a link, which is also very helpful, but I'm fuzzy on what happens with a regular query and what the fetch should look like.

ethangracer16:07:44

are you referring specifically to one of the examples? I don’t think there’s any one correct way to do it

curtosis16:07:47

which makes sense to load some data to a top-level key in app-state

curtosis16:07:15

but when I try to wire up a tab to have its local query work, things go pear-shaped

tony.kay16:07:14

@curtosis: the example uses a link to get to some dynamically loaded data

tony.kay16:07:26

otherwise the query is normal, and the app state is graph-natured

tony.kay16:07:34

A post-mutation could have been used to link (via an ident) to that data in the settings object in the db...and further nested components could have been used if deeper tree structure was desired out of the data (e.g. more normalization)

tony.kay16:07:21

The query is a union, and that part is what the example is concentrating on. The union itself doesn't affect the deeper structure

tony.kay16:07:43

So, imagine there are no tabs (e.g. just settings). Make the recursive structure as you would in any other case. Just build the graph. If something is going wrong it has to be one of just a few things: 1. The query is wrong 2. The resulting graph in the database is wrong (e.g. post mutation didn't hook it up correctly) 3. The ident function is wrong (e.g. maybe it didn't normalize properly) 4. Your initial app state isn't composed properly Either 1, 3, or 4 will cause 2...

tony.kay16:07:34

In general, there really isn't much to it. If the graph is right and the query is written in a way that follows it, then you should see data.

curtosis16:07:33

I'm not at all convinced my problem is only one of those few things. 😉

curtosis16:07:20

but that's a helpful way to think about what to look at.

tony.kay17:07:24

@curtosis: The cool thing about Untangled is that those few items comprise almost everything in the "normal" application pipeline. Unless you're doing some kind of React lifecycle addition or out-of-band processing (e.g. timeout/websocket)...the only other thing I can think of is UI refresh from follow-on reads. It's just a graph database, query, and mutations. Of course, you do have to pick the data apart and pass it through the UI tree...so there are additional silly kinds of mistakes to make. But nothing else in concept since the UI render tree matches the UI query tree.

tony.kay17:07:23

(which additionally also matches the initial UI state tree)

curtosis17:07:49

@tony.kay: agreed - that's why I'm using it! and the parts I do understand work superbly. 🙂

tony.kay20:07:56

@curtosis: Remember that you can run a query on a component, and you can join on an ident. So, you could, at the REPL, hand-write a join on a specific db item's ident to a component's query. Something like: (om/db->tree { [:some :ident] (om/get-query Settings) } db db)

tony.kay20:07:30

of course, throwing console log statements into each component to watch the data flow is another approach

ethangracer22:07:12

@currentoor @therabidbanana @jasonjckn have any of you used untangled datomic migrations to convert existing data into a new schema format? we are trying to refactor :category/name as :tag/name. Since :tag/name already exists in our database, we can’t just rename the :category/name attribute as :tag/name. So we have to copy the data from our old categories into new tag entities. Problem is, we don’t have access to the database connection in the migrations file.

therabidbanana22:07:24

Thus far we have been avoiding this issue by saying we're in alpha - old data might be lost. 🙂

therabidbanana22:07:58

I'd love to see some good examples of how to address doing complex transactions in a migration though

ethangracer22:07:04

yeahh we just passed that point!

ethangracer22:07:35

ok no worries, i’ll let you know what we come up with. I imagine that we will have to pass the database connection in somehow, otherwise migrations are going to be… interesting

currentoor22:07:31

I could see that being useful down the road.

tony.kay23:07:38

we found a good solution. Pretty simple. Ethan's coding it up