Fork me on GitHub
#fulcro
<
2021-11-27
>
Brandon Olivier18:11:13

How can I tell my dynamic router that some string should be interpreted as a uuid?

tony.kay20:11:21

You don’t. That is not a router’s responsibility, it’s yours 😄 You get the string, and you convert it. Simple enough for you to make helpers and such to configure such a thing. For example, you can put your own nsed keywords into the component’s option map, and get those with component-options. So, you could declare what types the parameters are, and then create a helper function that takes the class and route params and returns a map with things coerced. I’m not necessarily opposed to such abilities in the router, but a lot of the bits of Fulcro are intentionally minimal and aimed at getting the minimal thing working. You’re in a language where your own derivation is just a function or macro away.

Brandon Olivier20:11:04

I’m still learning fulcro, especially the vocabulary, but my issue seems to be that my query through a router isn’t giving me back the data from my database because it can’t follow an ident where string/uuid are mismatched.

Brandon Olivier20:11:26

When I use the db explorer to go through the database ident-by-ident, I get to this router’s “current-route” property, which needs to be something like [:user/id #uuid "some-uuid-string"] but the uuid reader tag is missing so nothing is found. That string (as a uuid) does correspond to a valid ident

tony.kay20:11:28

correct. Routers always have strings (and force parameters to strings) because those are universally available for resuming a route (paths are strings from browser). So, you will get strings for those params (embedded in the URL) in your will-enter

tony.kay20:11:13

you can use the (uuid v) to turn it into a UUID

Brandon Olivier20:11:53

I don’t understand where I can convert it so that the query finds the right data

tony.kay20:11:05

The point is that even if you originally used a UUID to route there, if someone were resuming the page through HTML5 routing, then you’d get a string. So, DR forces them to strings to make sure you hand;e that case.

tony.kay20:11:13

Where IS your query???

tony.kay20:11:20

in will-enter, right?

tony.kay20:11:50

it’s your code…I don’t know where you’re passing it, but I know Fulcro isn’t magically running a query for you, unless you’re using RAD, but that’s a different story.

tony.kay20:11:03

Where did you put the df/load!?

Brandon Olivier20:11:17

I was calling comp/get-query on the router to get the query and see where things seemed to be going wrong

Brandon Olivier20:11:30

Yes, I have a df/load in a callback on will-enter

tony.kay20:11:44

right, and that is where you’re getting this parameter, right?

tony.kay20:11:53

from the route params

tony.kay20:11:26

my guess is you used the raw string there instead of converting it to a uuid?

Brandon Olivier20:11:08

That sounds right. I ended up refactoring this code to use mutation joins to grab the data I needed, so I’m not 100% sure.

Brandon Olivier20:11:31

I’m going to work on changing it back to using a router and hopefully I can figure this out

Brandon Olivier20:11:39

Thanks for the help! 😄

Brandon Olivier20:11:56

I’m loving Fulcro, btw, thanks for that too

tony.kay20:11:25

Sure. So, this is a very old video I made back in the Untangled days (the old version of Fulcro based on Om Next). The basic concepts still apply and may be useful to you. Just understand the specific code references are outdated. I really need to remake it with pretty graphics (or at least readable 😜 ). The book covers this all, but sometimes its helpful to see something like this: https://youtu.be/mT4jJHf929Q

Brandon Olivier20:11:53

I got the code setup using the router, and I’m 99% sure I was not converting to a uuid in route-deferred. 😄

Brandon Olivier15:11:35

Yes! That was super helpful for me getting started (the fulcrobook can be intimidating at first)

Jakub Holý (HolyJak)15:11:43

The example in https://fulcro-community.github.io/guides/tutorial-advanced-minimalist-fulcro/#_loading_data_when_a_component_is_routed_to_for_the_first_time shows how to parse a route parameter from string into an int. It is the ± same for uuids and anything else. I guess that was not really clear from the text?

Brandon Olivier15:11:45

I think I just forgot to do the translation

Brandon Olivier15:11:54

There’s a lot of new info in Fulcro 😅

💯 1
Jakub Holý (HolyJak)15:11:11

Ah, ok. I am always looking for ways to make things clearer and decrease the chance for an error.

Brandon Olivier15:11:16

At this point, I think what would’ve been most helpful, post-conceptual understanding, would be a video/demo of how to go about building something fairly trivial. I feel like what I struggled with most was understanding how the various concepts and pieces fit together into the context of building something more realistic.

Brandon Olivier15:11:58

After building up some more confidence, I might try creating something like that myself 😅

Jakub Holý (HolyJak)15:11:27

Ok. I suppose fulcro-exercises helped you to get familiar with the basic stuff but you need the next step of st. more realistic and complete, right?

Brandon Olivier16:11:49

Oh dang, I need to be reading more resources, I hadn’t seen that before!

Brandon Olivier16:11:13

But overall, yes. In isolation, everything made sense fairly quickly, but connecting those isolated pieces was confusing for a bit.

👍 1