Fork me on GitHub
#pathom2018-10-23
>
mitchelkuijpers09:10:36

I am looking for some help I am currently fighting with joins in pathom, I am running pathom 2.2.0-beta14. And I am trying the following:

(defresolver `entity-autocomplete
  {::pc/output [{:entity/autocomplete
                 [::autocomplete/group-key
                  ::autocomplete/group-entity-type
                  {::autocomplete/items {:entity.type/company [:company/id :company/name :company/website :company/description]
                                         :entity.type/contact [:company/id :contact/name :contact/email :contact/description]}}]}]}
  (fn [{:keys [ast] :as env} _]
    {::pc/env (assoc env ::p/union-path :entity/type)
     :entity/autocomplete search-results}))
When I run the following test:
(is (= (test-parser env
             [{'(:entity/autocomplete {:filter-value "Av"})
               [::autocomplete/group-key
                ::autocomplete/group-entity-type
                ::autocomplete/items {:entity.type/contact [:contact/id :entity/type]
                                      :entity.type/company [:company/id :entity/type]}]}])

           [{::autocomplete/group-entity-type :entity.type/company
             ::autocomplete/group-key :atlas-crm.domain.autocomplete.group-key/search-results
             ::autocomplete/items [{:company/id 1
                                    :company/name "Avisi"
                                    :entity/type :entity.type/company}]}]))
I am getting very weird output which I don't expect I am getting a :entity.type/contact :com.wsscode.pathom.core/not-found below :entity/autocomplete which I don't expect

mitchelkuijpers09:10:47

This diff shows it more clearly

wilkerlucio11:10:36

hello @mitchelkuijpers, long time 🙂 what reader are using you using? the regular pc/reader?

wilkerlucio11:10:51

@mitchelkuijpers I just noticed your query is missing the {} around the ::autocomplete/items join

mitchelkuijpers11:10:18

Thank you so much!

wilkerlucio11:10:50

and the output should be a map insteadf of a vector, but I guess that will show up quickly there now, hehe

mitchelkuijpers11:10:52

@wilkerlucio We are using pc/reader but I as peeking into parallel reader

wilkerlucio11:10:20

cool, if you are going from the serial parser you have some things to check during the migration

wilkerlucio11:10:29

I'm gonna write more about it, but the main thing is sync vs async

mitchelkuijpers11:10:59

Nice this totally fixes it! We looked at it with 3 persons but no-one noticed 😛

mitchelkuijpers11:10:29

Can the parallel reader do smarter batches? Because then it would be very interesting

wilkerlucio11:10:49

people migrating from async parser will have no work do to, but if you wrote plugins or you do recursive parser calls in your resolvers, then you need to change some things to support async because the parallel is async

wilkerlucio11:10:10

it can do the same batch the serial does, is that one or you are thinking on something different?

mitchelkuijpers11:10:33

Ah we don't do recursive parser calls we just use connect

mitchelkuijpers12:10:03

Not sure, we will do load-testing next week so we might try out both and report back if the parallel gives a big speedboost

mitchelkuijpers12:10:05

I would guess so

wilkerlucio12:10:35

cool, another thing to watch out is the ::pc/env thing, that just doesn't work on parallel due to how it process the query, I'm replacing it with ::p/env that will work in a lower level and should work to port, but I have to verify if it's working in all expected cases

mitchelkuijpers12:10:53

Ah ok would be interested in that. But we acdtually added it to the env-plugin: ` ::p/union-path :entity/type `

wilkerlucio12:10:01

at same time, for unions we have a different standard solution as well, that I think fits more easely in the connect way

mitchelkuijpers12:10:16

Ah ok would be interested in that. But we actually added it to the env-plugin:

::p/union-path :entity/type

wilkerlucio12:10:16

oh, if you have that static, then all good

mitchelkuijpers12:10:48

And if we need more options I would make that a function

wilkerlucio12:10:59

in previous versions if you didn't provide the ::p/union-path then it would raise an error on unions, but that changed

mitchelkuijpers12:10:07

Yes I noticed, very nice change

wilkerlucio12:10:16

now the default is a fn that tries to find the union branch as a prop on the entity

wilkerlucio12:10:26

easier to code than explain XD

wilkerlucio12:10:28

(defn default-union-path [{:keys [query] :as env}]
  (let [e (entity env)]
    (if-let [path (some->> (keys query)
                           (filter #(contains? e %))
                           first)]
      path)))

mitchelkuijpers12:10:48

Ah nice, that is fancy

mitchelkuijpers12:10:05

I gotta to but thank you so much for spotting the derp

wilkerlucio12:10:27

no worries, glad to talk to you again, its been some time

😄 4