Fork me on GitHub
#pathom
<
2022-06-28
>
mbjarland14:06:44

seems this example from the pathom 3 docs does not work:

(def parallel-env
  (-> {::p.a.eql/parallel? true}
      (pci/register
        [random-dog-image
         random-cat-image
         random-pets])))
...or perhaps that's just me not getting it to work. How should I enable parallel execution assuming the above is not the way?

wilkerlucio17:06:49

hard to infer just from this, can you show the complete example?

wilkerlucio17:06:37

so far looks correct, but you also need to make sure to use the async runner, and remember that the async runner returns a promise (that will resolve to the final value)

mbjarland08:06:14

I think I had a problem with the namespace qualified keywords and the fact that almost none of the code snippets at don't show the (:require [ ... :as ...]). I finally found your namespace alias list at the start of the documentation set so I think that just solved my problem : )

mbjarland09:06:20

@U066U8JQJ ok so now I have something I think perhaps should be working but the requests do not seem to be executed in parallel. Should this be enough to enable parallel execution:

(def env (-> {::p.a.eql/parallel? true}
             (pci/register (concat swapi/resolvers
                                   imdb/resolvers
                                   [swapi->imdb imdb->swapi]))))

(comment
 (time
  ; deeply nested query combining swapi and imdb
  @(p.a.eql/process env
                    {:swapi.person/id 1}
                    [:swapi.person/name
                     {:swapi.person/homeworld [:swapi.planet/name
                                               {:swapi.planet/residents [:swapi.person/name]}]}
                     {:swapi.person/films [:swapi.movie/title
                                           {:imdb.movie/actor-list [:imdb.person/name
                                                                    :imdb.person/id
                                                                    :imdb.person/as-character
                                                                    {:imdb.person/known-for [:imdb.movie/title :imdb.movie/year]}
                                                                    ]}]}]))
)
? I have some logging in my request function and I can see they are all being executed in sequence