Fork me on GitHub
#fulcro
<
2018-07-31
>
arohner18:07:26

Hi, I’m trying to use fulcro-sql, standalone. I’m trying to pass a #uuid in the root set, and it appears the query is choking

arohner18:07:52

…WHERE foo.bar.id IN (11ad4ac0-96c6-48f4-97a8-07d3f46acec5)] nil

arohner18:07:40

If I pass “?” as a root set, the query is correctly interpreted as wanting params, but I don’t see a way to pass them in to query?

currentoor18:07:45

is :ui/loading-data supposed to work with a websockets remote?

tony.kay19:07:43

@arohner fulcro-sql assumes your ID will be understood in an IN clause as-is, and does no interpretation. UUIDs won’t work in SQL the way it is embedding them 😞

tony.kay19:07:28

@currentoor you mean load markers?

tony.kay19:07:04

load makers happen at a higher layer than remotes, so yes, they should work as documented

tony.kay19:07:15

for loads, of course 🙂

currentoor19:07:32

oh this is for mutations that happen over websockets 😅

tony.kay19:07:43

nope…not a load, so no load marker

tony.kay19:07:03

Although I think the global activity marker is supposed to light up, which is what you’re talking about, right?

currentoor19:07:27

> Thus, only the global activity marker is available for mutations.

tony.kay19:07:20

erm, the documentation is wrong

currentoor19:07:27

it lights up for file uploads happening over http, but not for websocket requests though fulcro inspect correctly displays both as pending when they are pending

tony.kay19:07:23

well, I suppose technically it should probably be considered a bug, since you might want to know when mutations are still in flight

currentoor19:07:29

yeah that’s what i needed

currentoor19:07:27

though, since i’m using ptransact for this particular call i suppose i could just add a custom load marker before and after my blocking mutations

tony.kay19:07:14

It’s kind of a messy thing to track, actually, since there can be an arbitrary number of remotes running either loads or mutations, the latter of which are just closed over in an async network op

tony.kay19:07:49

loads are relatively easy, since we track load markers to keep track of what we’re doing with the returned data.

tony.kay19:07:44

combine that with the fact that you can make non-sequential remotes (where you could have many mutations in flight at once) and it gets really tricky

tony.kay19:07:43

actually, it might be tractable to fix. send-payload in application.cljc is the central spot where callbacks are composed for the async process…we could add a (atom #{}) in the reconciler (requests-in-progress), assign each network request a UUID, and just make the callbacks remove their UUID when done. “active network” would just mean this set was non-empty.

tony.kay19:07:32

I don’t have time to test it, but if you’re interested I could show you approximately what to do

currentoor19:07:41

i’m a little pressed for time at the moment, i’ll make a notes of what you’ve said above and revisit later, in the meantime i should be able to get by with a custom load-marker (that’s tied to this specific mutation finishing)

tony.kay19:07:44

Actually, I think the reconciler might already track that…

tony.kay19:07:05

take a look at (-> reconciler :state deref :queued-sends)

tony.kay19:07:26

note that is not app state

tony.kay19:07:51

an unfortunate naming badness…the app state is in (-> reconciler :config :state deref)

currentoor19:07:57

but wait in app state there’s also :fulcro/loads-in-progress

currentoor19:07:59

what about that?

tony.kay19:07:10

that is the actual load queue

currentoor19:07:20

oh, not mutations, got it

arohner19:07:41

@tony.kay are you interested in a PR to accept the root set as a param?

currentoor19:07:52

@tony.kay i’ll try what you just suggested

tony.kay19:07:56

I’m open to it, but I’m not spending much time on that particular lib. The advent of pathom and walkable https://github.com/walkable-server/walkable sort of make it obsolete

tony.kay19:07:07

Mine was more of a proof of concept to show people one way to go about it. These days I would personally use pathom https://github.com/wilkerlucio/pathom as a general-purpose solution.

tony.kay19:07:34

and walkable if you like the notation

arohner19:07:37

ah, didn’t know about pathom. Walkable doesn’t yet support postgres schemas

tony.kay19:07:07

Pathom is just a completely general way to build parsers easily for the server-side processing. Data source doesn’t matter, and it makes it easy to build.

tony.kay19:07:46

You will have to be careful with the possible N+1 query problem, but that is solvable (walkable is actually written on top of pathom, I believe)

tony.kay19:07:29

it shows a couple ways of doing it, and the timestamp I’ve embedded is roughly where I talk about using pathom connect with SQL.

currentoor19:07:08

:queued-sends appears to be empty the whole time

tony.kay19:07:43

yeah, I didn’t write that bit, so it isn’t surprising to me 🙂

tony.kay19:07:54

I certainly haven’t been maintaining anything in there

tony.kay19:07:52

@arohner Given that your desired UI query often doesn’t match your database, pathom connect is super useful to “invent” UI graph parsing against your database (or any data source).

wilkerlucio20:07:38

@currentoor in fulcro incubator I have some snippets from code to handle progress over mutations, there is a limitation that you can't track more than one event per identity, but it can take some time until this gets to be a real problem: https://github.com/fulcrologic/fulcro-incubator/blob/develop/src/fulcro/incubator/db_helpers.cljc#L304-L343

currentoor21:07:24

thanks @U066U8JQJ i’ll check it out

wilkerlucio21:07:53

np, also check the defpmutate macro, it can help to generate the mutations for the process: https://github.com/fulcrologic/fulcro-incubator/blob/develop/src/fulcro/incubator/db_helpers.cljc#L259-L267