Fork me on GitHub
#om
<
2016-12-12
>
danielstockton12:12:33

is there anything in the om next query syntax that doesn't translate to graphql?

danielstockton12:12:56

im wondering whether to write my own parser, or translate the query into graphql where a number of backend implementations already exist

jonsmock17:12:00

Anyone else changing the :compassus/route in their merge function? Or is that a terrible idea?

jonsmock17:12:41

Attempting to change routes after a successful remote mutation (but not if there was a problem)

anmonteiro17:12:56

@jonsmock I think @danielstockton was doing it at some point

anmonteiro17:12:16

I don't think that it would cause any complications

jonsmock17:12:20

Ok, sort of sanity checking - thanks!

anmonteiro17:12:31

let me know if it does

jonsmock17:12:49

Looks like it is working, and it does trigger a re-query for that new route

danielstockton17:12:52

I did try it but unsuccessfully

danielstockton17:12:58

it seemed to have no effect

jonsmock17:12:10

(btw, sorry :compassus.core/route not :compassus/route)

danielstockton17:12:39

correction, it's set-route that didn't work

jonsmock17:12:50

I must be doing something else incorrectly. It triggers a query to my new route's query, which triggers a remote read

jonsmock17:12:57

And the remote read doesn't happen for some reason hmm

danielstockton17:12:03

merging c.core/route worked I think

jonsmock17:12:50

Ok maybe a dumb question, how do ya'll debug a remote read not happening?

jonsmock17:12:17

Not sure where to hook in to test or where to break that apart (i.e. Stu's scientific method talk)

jonsmock17:12:03

This is sometimes something I struggle with that I haven't completely figured out, probably something basic I'm forgetting

jonsmock17:12:42

To recap: parsing happens with target nil and parser returns :remote true, and then I never see the parser called again with the remote target

anmonteiro17:12:15

@jonsmock Om Next won't make any remote calls in merge

jonsmock17:12:17

An no query sent to remote either

jonsmock17:12:44

Oh maybe I'm missing when this happens. Here's my mental model now

jonsmock17:12:29

1. merge changes compassus route, 2. om notices and triggers query for new root component, 3. parser gets called with query and returns {:remote true}

anmonteiro17:12:11

what you're missing is: the parser either gets called with target set to nil or to a remote name

jonsmock17:12:15

I assume 2 happens after the merge changes app state

anmonteiro17:12:52

whenever you transact!, the parser is called twice. Only when target is non-nil it goes and sees what's in the :remote key that you return

anmonteiro17:12:12

but in merge, the parser is only called once, with target set to nil

anmonteiro17:12:34

this is by design, or you could end up in an endless remote loop

jonsmock17:12:45

Ok, so #3 is happening as part of the merge?

anmonteiro17:12:11

#3 happens as part of the reconciliation phase

jonsmock17:12:11

I figured the merge was "completed" and then #2 happened

anmonteiro17:12:20

this occurs because merge queues something to be reconciliated

anmonteiro17:12:35

so it's effectively after merge

anmonteiro17:12:45

but because merge wanted it to happen

jonsmock17:12:06

So #3 will happen with target set to nil, and it won't notice the :remote true if I return it

anmonteiro17:12:37

the :remote key is just ignored (because the parser was called with a nil target)

anmonteiro17:12:12

if you need to perform a new remote read, you can probably use set-route!

anmonteiro17:12:21

that'll call transact! and go remote

anmonteiro17:12:36

I assume it only happens in the successful case

jonsmock17:12:42

I assume I don't do that from within the merge, though, or is that what you're suggesting?

jonsmock17:12:54

Yeah, only on success, right

anmonteiro17:12:37

I suppose you can do that from within

jonsmock17:12:18

The other thing I can think of is to have a channel that merge puts something in on success

jonsmock17:12:24

Not sure if that's too hacky

anmonteiro17:12:27

you probably need to be careful about the heuristic you use to check when that needs to happen

anmonteiro17:12:39

sounds hacky

anmonteiro17:12:29

using the componentDidUpdate React lifecycle hook to do a transaction would probably be less hacky

anmonteiro17:12:40

keep in mind that you can also transact! a read

anmonteiro17:12:56

(om/transact! this [:some-key-to-read])

jonsmock17:12:36

I see - I was just about to ask if my merge assumption was correct (i.e. that merge is the only thing that can notice that a successful response came back)

jonsmock17:12:15

But I think you're suggesting that the original component's componentDidUpdate watches for the successful response to be merged

jonsmock17:12:25

And does the route change mutation

jonsmock17:12:36

I can resay that in clearer terms if that didn't make sense

anmonteiro17:12:45

you understood correctly 🙂

jonsmock17:12:49

Awesome, thanks

jonsmock17:12:55

That makes a lot more sense

anmonteiro17:12:59

consider componentWillUpdate too

jonsmock17:12:01

Puts the control back into the component

anmonteiro17:12:20

and work with the one that feels best

jonsmock17:12:33

Cool - thanks for explaining that all to me!

jonsmock17:12:38

Awesome seeing you at the Conj too

jonsmock17:12:55

Hope you had fun

anmonteiro17:12:06

no problem, and likewise!