Fork me on GitHub
#fulcro
<
2022-10-06
>
Eric Dvorsak14:10:36

Did anyone had success using fulcro-rad-sql with pathom3? looks like sql/wrap-env is never called with the example code in the fulcro-rad-demo fulcro3 branch

Eric Dvorsak16:10:23

ok it was only the case when running queries within pathom viz

norman19:10:44

I've read the docs and tried to look back through chat history, but I'm still not not clear how to make sure that ::merge/not-found isn't passed to my components. • df/load! loads data from server has many fields that may be nil • I see from the transit response those nil values are being sent (I am using pathom/elide-special-outputs-plugin, if that matters) • In the client db, I see that value ::merge/not-found • When a component queries that attribute from the db it gets ::merge/not-found and doesn't get nil, which is what I really want to get. I really want to get nil when I query those attribute from a component.. So my first question is - am I doing something wrong? I see reference to sweep-merge , which is supposed to remove these values. When should this be called? Could I be doing something to cause it not run correctly?

norman19:10:33

If I'm not doing something wrong and it's expected that not-found propagates to the UI if I don't do anything, I can: • Call nillify-not-found from my components every time access the value. (YUCK) • Be diligent on the server to never return nil. (mostly works, but this really isn't the data I want to be sending) • Do something in pre-merge for every load event I'm concerned about. I'm also not clear, based on the examples, what the "correct" behavior is. I can write things that look like they are doing what I want, but I'm not entirely clear. Is there a clear example of what to do? None of the examples in the book seem like what I want.

tony.kay21:10:45

you do not want nil in app state if you can avoid it. Not founds are retracted, not set to nil

tony.kay21:10:02

where are you seeing not-found values? pre-merge? They are supposed to be there, because you might find them useful.

tony.kay21:10:24

but they should not be in the client db

norman21:10:06

Yes, I see ::merge/not-found in the data that gets to pre-merge

tony.kay21:10:08

Fulcro is very pluggable…so, first question would be if you’re doing anything non-stock

tony.kay21:10:23

as in setting the transactioin handler, adding in middleware in places, etc.

tony.kay21:10:58

but yes, it is supposed to be visible in pre-merge. The sweep-merge happens after pre-merge

tony.kay21:10:20

they are there so that a merge of various layers in pre-merge will work “right” semantically

norman21:10:50

I'm not doing any special configuration that I can see in initializing the app that would add any extra middleware or do anything unusual

tony.kay21:10:07

So, confirm that you are seeing the not-found values in the client db after load is done, and you look at db in Inspect

tony.kay21:10:48

This is an odd corner case, and in practice you should never return nils in maps from EQL requests. nil is not considered a legal value from a data perspective in Fulcro (the absence of the key is the proper way to indicate no value for a key). You can easily put a plugin on pathom that will dissoc keys w/nil values. That said, I would consider it a bug if a nil is returned and the not-found marker ends up in app state

norman21:10:35

and to confirm it is sending nil... I do have elide-special-outputs-plugin on the server side

tony.kay21:10:22

What is your component query?

tony.kay21:10:33

I just tried it on my app here, and it is NOT in app state

tony.kay21:10:40

even though I returned nil

norman21:10:26

:query [{:project-parent/proposal
            [:proposal/design-name
             :proposal/estimate
             :proposal/faqs
             :proposal/team-members
             :proposal/timeline
             :proposal/what-we-heard]}]

norman21:10:30

very straight forward

tony.kay21:10:42

that is not a proper query

tony.kay21:10:00

the nested bit has no component, and therefore no normalization info

tony.kay21:10:09

it’s legal EQL

norman21:10:26

And then I load as

(df/load! app
                  project-ident
                  ProposalData)

norman21:10:48

Where project-ident is entity in question I'm querying

tony.kay21:10:50

so, this is technically a bug in Fulcro

tony.kay21:10:19

The internals assume you’re always going to do joins on components that themselves have queries.

tony.kay21:10:44

the fact that you are not normalizing the nested item is what is confusing it I think

norman21:10:14

Ah - so if I were put this on the parent entity and used :focus (or whatever the keyword is to target only some sub-query) for example, then fulcro would be happy

tony.kay21:10:15

I’m not sure why it is breaking on that…I’m looking at the internal logic and I don’t see a problem

tony.kay21:10:01

So, forget focus or without for a moment

tony.kay21:10:56

if it was a flat query then it would work. Also, it would work if you had:

:query [{:project-parent/proposal (comp/get-query Proposal)}]
where Proposal queried for an id and had an ident and therefore was normalized

tony.kay21:10:02

which is what you want 99.99% of the time

tony.kay21:10:55

Write a second “kind* of proposal component to avoid self-reference

tony.kay21:10:27

(defsc ProposalA {:ident :proposal/id …}) (defsc ProposalB {:ident :proposal/id …})

norman21:10:03

Hmm - this data doesn't have an ident, though I suppose I could borrow the id of the parent object....

tony.kay21:10:33

unless you need true recursion, in which case

(defsc Proposal [this props]
 {:query [:proposal/id {:proposal/parent ...}]
  :ident :proposal/id}
...)

tony.kay21:10:38

or you can flatten the query

tony.kay21:10:11

or you can try to find the bug with non-normalized mark/sweep merge. 😄

tony.kay21:10:59

If you want to make a very minimal repro project and send it along, I’ll have a look at it sometime

norman21:10:52

Ok - I'll see about trying to hack on some kind of id here for now. And yeah, it should be easy to come up with a reproduction

❤️ 1