https://kotlinlang.org logo
#graphql-kotlin
Title
# graphql-kotlin
r
d

Dariusz Kuc

04/21/2020, 2:44 PM
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

Robert

04/21/2020, 2:45 PM
any plans, as this lib is called graphql-kotlin 😇 Or use
CompletableFuture.completedFuture
and use a coroutine to return that value?
d

Dariusz Kuc

04/21/2020, 2:45 PM
*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

Robert

04/21/2020, 2:49 PM
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

Dariusz Kuc

04/21/2020, 2:50 PM
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

Robert

04/21/2020, 2:55 PM
perfect, will read through that
d

Dariusz Kuc

04/21/2020, 2:58 PM
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

Robert

04/21/2020, 4:14 PM
will let you know
111 Views