Fork me on GitHub
#graphql
<
2022-04-20
>
favila03:04:43

in Lacinia, is there any way to convince the execution engine to run the resolvers for each item in a collection in parallel? I’m returning a vector of datomic entity maps, and from the tracing data it looks like it’s running the field resolvers for each map in the collection serially. I.e. it’s doing “map” but I want “pmap”

favila04:04:45

I know about this, but this is about resolving an individual field/value. I can’t see how this can give me any control over the parallelism of nested resolvers

vlaaad05:04:07

There is https://github.com/vlaaad/plusinia that allows parallelizing (and batching) resolution process, at the expense that you have to opt-in for every resolver to work on a set of values instead of a single value

vlaaad05:04:11

Ah, you know about it already..

favila05:04:07

I think in my case I have an alternative. My return value is actually [{:node v1} {:node v2},,,] (think Connection like result https://graphql.org/learn/pagination/#complete-connection-model). So I can make the resolver for :node return a promise which I immediately (asynchronously) deliver, and then I know the on-deliver chain of resolvers lacinia attaches will run in parallel. That’s enough parallelism for me in this case. It seems to work! I deliver the promise value using an agent send, but set the *callback-executor* to the agent send-off threadpool because those other resolvers may involve IO.

favila05:04:39

If I didn’t have that extra nesting via the :node field to rely on, I’m not sure what I could have done here.

timrichardt11:04:34

Hello everybody! I'd like to announce [io.github.timrichardt/hicgql "0.1.0"] , a tiny library I wrote to create GraphQL documents in ClojureScript. It's modeled after Hiccup and should cover the whole GraphQL spec. I am happy for any feedback. https://github.com/timrichardt/hicgql

❤️ 4