Fork me on GitHub
#fulcro
<
2021-07-10
>
genekim01:07:33

@tony.kay Thanks for all the help today! I have a question about resolvers —  1. Resolver (a) is the :story/all-stories resolver — I’m attempting to indicate in pc-output that I’m passing back not just :story/id, but also :story/author and :story/title Does Fulcro / Pathom understand that those attributes are in the response, and it doesn’t need to fetch those again? 2. If resolver (b) is cheaper than resolver (c), and given that there are 8K records, can Fulco / Pathom detect when use (b) instead of (c), if I’m not asking for story/content? (I’m finding that this query below uses Resolver (c), even though I’m not asking for :story/content.)

[{[:story/id
     "K3Y7GLlRfaBDsUWYD0WuXjH/byGbQnwaMWp+PEBoUZw=_16f54f2e5c5:21c7d86:bb2cd839"]
   [:story/id :story/title]}]

tony.kay02:07:36

1. Yes 2. More advanced Pathom...you should probably concern yourself more with batch mode, but these are more #pathom questions

tony.kay03:07:37

The short answer is pathom in your case will start with (a), because it has to. If some of the things are resolved and returned by that resolver, then it will only go looking for the remainder. Of course (b) has to be used if you want the title/author, because you've not told it anywhere else to get that from, and (c) would have to be used to get content; however, if either of those returns things it didn't advertise, then pathom won't need to call the other. The reason I say batch is more important is that if you have 1000 stories and no batch more enabled, these resolvers are going to get called 1000 times instead of just once.

tony.kay03:07:53

You're better off having a single resolver that looks at the incoming query in evn and adapts the database query to the requirements of the request. That way, with batch enabled, you can get exactly the details required with possibly jsut one query

genekim03:07:08

So cool! And so much fun! Thank you!!

genekim21:07:32

@U066U8JQJ I’m looking in the Pathom documentation on how to retrieve the desired output vector from the env — can you give me any hints on where to find it? Thank you! (I see (:ast env) gets me {:type :prop, :dispatch-key :story/title, :key :story/title}, but that’s obviously not it.) (I’m trying to detect when the query is requesting the :story/content attribute, which is the “expensive” part of the query.).

wilkerlucio21:07:37

@U6VPZS1EK you can use ::p/parent-query from env, that will have the sibling attributes, its rudimentar but you can try to find the attribute there

wilkerlucio21:07:00

the way its rudimentar is that you will only be able to see if it its a explicity dependency (meaning the end-user requested it)

genekim21:07:38

Ooh! There it is! Thank you!!!

wilkerlucio21:07:49

but there could be a case that a resolver needs that information, but the user doesn't request it, in this case, if you are using this as a way to "don't query the expensive thing", you may end up in a situation where it is required, but you didn't got it

wilkerlucio21:07:29

this is a fixed problem in Pathom 3 btw, there you can see precisely everything required, explicit or implicit

genekim21:07:10

Wilker, I think this is exactly what I need to compose the actual “database query” (which is actually just an EDN file loaded into the server.) Just curious: where should I have found this in the docs? Or is this not something you expect people to do?

wilkerlucio21:07:56

Pathom 2 docs are kinda lacky, this is the kind of thing you can find asking us or readying sources. logging the whole env is a nice way to explore for sure

wilkerlucio21:07:22

trying to do a better job about those in Pathom 3 😅

tony.kay21:07:42

logging the keys of the env. 😄 Logging the env is madness

wilkerlucio21:07:26

in the server console I agree, but if using the browser, or something like Reveal, then its nice

tony.kay21:07:57

yeah, tapping the env is nice

wilkerlucio22:07:11

@U6VPZS1EK what you using to see the data in the screenshot you sent?

genekim22:07:46

That’s from Portal — I’ve tried REBL, then Reveal, and then Portal. I really like it, and there’s something nice about it running in a browser, versus JavaFX.

genekim22:07:13

(Small things like copy/paste always acting like you’d expect.)

genekim22:07:27

I literally just added Portal to my Fulcro RAD development.clj file this morning. Took less than 2m to add, from opening deps.edn to getting tap> displayed!

genekim22:07:43

(Called it a night when I logged entire env going into defresolver, wondering where parser query was. 🙂 My reaction was, “Whoa. Maybe I’ll have more clarity tomorrow” 🙂 😆

genekim22:07:39

Like @tony.kay said, my reaction was, “searching through that might lead to madness, especially at 1am.” 🙂

wilkerlucio22:07:42

cool, I'll give portal a try

wilkerlucio22:07:53

I like reveal but dealing with JavaFX when I want to extend it is quite painful

genekim22:07:03

@tony.kay @U066U8JQJ Thanks for help on Pathom query stuff — finally got render time for displaying a specific RSS story down to.. nearly instantaneous! Down from 3/4 of a second. 🙂 🎉 (PS: Let me know how Portal goes! It’s what finally got me to start using on all projects.)