Hey, does `DataLoader`support kotlin coroutines? U...
# graphql-kotlin
r
d
afaik not natively
you could invoke coroutines from within the data loader logic but i guess you would have to create your own scope
which i guess would break the structured concurrency
r
any plans, as this lib is called graphql-kotlin 😇 Or use
CompletableFuture.completedFuture
and use a coroutine to return that value?
d
*I might be wrong as we don’t use it and don’t have much experience with it.
linked config just registers a data loader so unsure how much we would get form it being a coroutine
org.dataloader.DataLoader
signatures we dont control
I would love to drop the
graphql-java
dependency on
CompletableFuture
and provide some native execution engine
but unsure when (or if) that ever happens
r
Good Point 👍 Maybe I don't even need a DataLoader at all .. as there are queries with corutines https://github.com/ExpediaGroup/graphql-kotlin/blob/master/examples/spring/src/main/kotlin/com/expediagroup/graphql/examples/query/CoroutineQuery.kt
d
we don’t use data loader within Expedia so don’t have much experience with using it
👍 1
my understanding is that it provides you some batching/caching capabilities
guess its usefulness would really depend on the type of the queries you got
for us its not that useful
and yeah all our queries are implemented as coroutines
r
perfect, will read through that
d
note: unfortunately due to the dependency on
graphql-java
CompletableFuture
there is still broken parent-child relationship between query handler (e.g. web filters, routing and construction of gql request) and actual query execution
👍 1
so currently we have
coroutine
->
completable future
->
coroutine
if you need custom coroutine scope (e.g. MDC) for your queries you will need some custom data fetcher that populates it
*thats what we currently do internally, if you find better way let me know 🙂
r
will let you know
130 Views