I watched <this> amazing talk on ktor graphql from...
# graphql-kotlin
a
I watched

this

amazing talk on ktor graphql from KotlinConf’23, Amsterdam yesterday. Amazing talk! I’m now curious about how ktor and kotlin graphql solves the n+1 problem that we generally encounter in graphql servers. I couldn’t find any resources on how ktor solves that. Does any one know how that’s done in ktor? Thanks.
d
👋 folks generally use data loader pattern to batch requests downstream (see https://opensource.expediagroup.com/graphql-kotlin/docs/server/data-loader/#dataloaders-and-coroutines)
a
Oh, this is great. Thanks, will check it out!
g

This

presentation about data loader 3.0 might also be interesting.
d
I watched it expecting some fundamental rewrite.... but it was nothing new
graphql-java
resolves queries in a breadth first matter (afaik all graphql libs do) - it will gather all available futures (for given level) and then await for the first leaf value. It actually even does an extra optimization by checking for sync leafs - so it will actually traverse far down the tree until all fields are futures before waiting for them. This is actually what Sam implemented with sync exhaustion strategy for the batch dataloader.
As for federated resolver -> thats what the query plans are for (so using Apollo router you end up with 4 fetches and definitely dont use thread per id)... so again nothing new on that front 🤷
I did like the will it compose game though :)