Fork me on GitHub
#pathom
<
2020-05-04
>
Matthew03:05:34

@wilkerlucio I was using the async-parser, then I read the docs further and saw that the parallel-parser is the recommended approach. The result from the parallel parser gave me the single core async channel that I expected. I was a little confused reading the docs, but I think it’s just that they haven’t been consistently updated as of yet.

wilkerlucio04:05:10

@matthew_lefebvre I suggest you keep on the async-parser unless you have a lot of paralellizable things (which is not common)

wilkerlucio04:05:07

sorry the confusing docs, they are a result of trying to upgrade it step by step

Matthew04:05:16

Is your recommendation performance based, base on a node (single threaded) environment?

wilkerlucio04:05:40

yeah, the parallel parser is much more complex, so debugging around it is much harder

Matthew04:05:45

I’m pretty sure nothing parallel is happening in the JS runtime unless there are workers involved in the implementation

wilkerlucio04:05:33

and if you don't have concurrent situations (can be on a single thread), it is slower

wilkerlucio04:05:47

it cna go in parallel on node, when you do async things, for example, you can have multiple async requests (external http requests for example) going in parallel, even on the single thread

Matthew04:05:22

Yea sorry, I understand what your saying if you mean all the IO threads running outside of the event loop. It’s interesting that you suggest the async parser. I didn’t really understand the way my parse results were returned to me, then the parallel parser just sort of did exactly what I was expecting.

Matthew04:05:02

With the async parser the channel is inside a returned map. Where as with the parallel parser the entire returned value is a channel that you take from and all your data is there exactly in the shape your expecting.

Matthew04:05:27

I don’t think my async parser was configured correctly

wilkerlucio05:05:09

@matthew_lefebvre with the async parser you must async-reader2

sergey.shvets05:05:16

@wilkerlucio is there a special reader needed to be included to enable eql params support?

sergey.shvets05:05:22

I'm unable to get params in :ast for ident. https://github.com/edn-query-language/eql#parameters. I tried both syntaxes.

wilkerlucio06:05:24

@bear-z they are supported by default, the main issue people have with this is the expectation about where this should appear, can you send me the query you are trying to process?

sergey.shvets06:05:53

(def sub-list-query ['({[:hand-and-foot.game-rounds/where {:hand-and-foot.game-rounds/number 1}] [{:hand-and-foot.game-rounds/list [:hand-and-foot.game-rounds/id]}]}
                         {:hand-and-foot.games/id "TKSbTbE6O5Q0U89JhuHc"})])

sergey.shvets06:05:56

Sorry, one more question: can you nest joins more than one level?

wilkerlucio06:05:10

@bear-z yes you can, and your query, the param will come ont he ident join, but you are probably trying to read them from the child level

wilkerlucio06:05:50

othen than that the query seems write, altough there is a different way that also works that I find cleaner:

(def sub-list-query
  [{'([:hand-and-foot.game-rounds/where {:hand-and-foot.game-rounds/number 1}] {:hand-and-foot.games/id "TKSbTbE6O5Q0U89JhuHc"}) 
    [{:hand-and-foot.game-rounds/list [:hand-and-foot.game-rounds/id]}]}])

wilkerlucio07:05:02

this is cleaner IMO because it puts the param on the side of what they target

sergey.shvets07:05:39

Thanks, how do I access them in resolver if they're added on ident level?

wilkerlucio07:05:56

what people usually do is to write a plugin to propagate params down via env

wilkerlucio07:05:31

on the #fulcro channel that question has appeared multiple times, probably someone there has the snippet for it :)

sergey.shvets07:05:52

Cool. I'll research that path then.

sergey.shvets07:05:47

Back to joins: I'm trying to do a query that will read games->rounds->moves . I have resolver for rounds that takes as input game-id. This works fine. The second resolver for moves requires both game-id and round-id and it unable to find it. Both rounds and moves expect to return list of items.

sergey.shvets07:05:47

Will the response from level 0 be available on level 1 or I have to somehow propagate it?

wilkerlucio07:05:17

not automatically, but thats a pattern I have done a couple times, on the rounds resolver you can pass the game-id down to the next entity

wilkerlucio07:05:41

that's a reason why the big names are so important

sergey.shvets07:05:51

So, I just need to include it in return of the rounds and then it will figure it out?

wilkerlucio07:05:31

yup, it just needs the data to exist on the entity, or have a path to find it

sergey.shvets07:05:35

I tried to pass it as :pathom/context but that doesn't seem to work

wilkerlucio07:05:49

not context, you really just mesh it down

sergey.shvets07:05:59

I think I get it now.

sergey.shvets07:05:41

Btw, is :pathom/context a correct keyword? All the rest of keywords are prefixed with core or connect namespace.

wilkerlucio07:05:48

something like:

wilkerlucio07:05:49

(pc/defresolver rounds [env {:keys [game/id]}]
  {::pc/input  #{:game/id}
   ::pc/output [{:game/rounds [:game/id
                               :round/whatever]}]}
  {:game/rounds (->> (get-rounds rounds id)
                     (mapv #(assoc % :game/id id)))})

sergey.shvets07:05:03

Got it. Will try it and report the results. Thank you so much for the help @wilkerlucio. I would probably spend weeks to figure this out on my own!

wilkerlucio07:05:01

no worries, glad to help