graphql

favila 2022-04-20T03:16:43.157439Z

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”

favila 2022-04-20T04:02:45.597359Z

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

vlaaad 2022-04-20T05:29:07.389909Z

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

vlaaad 2022-04-20T05:30:11.608529Z

Ah, you know about it already..

favila 2022-04-20T05:53:07.509269Z

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.

favila 2022-04-20T05:53:39.716159Z

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.

timrichardt 2022-04-20T11:32:34.725449Z

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