Closed hantsy closed 6 months ago
I'm not sure that's how the implementation would work out. In general, it is more helpful to describe the ask rather than a solution. Also this overlaps with #406 and #407 while the title here is broad enough to cover all three.
If you could please, edit the description to describe all the places where you'd like to see Kotlin support. I'm gong to close the other two issues as duplicates. If we need to create sub-tasks we will, but for the requirements I see no reason to have multiple issues.
OK, I listed all of my thought and issues I found when creating the Spring GraphQl/Kotlin Coroutines example project: https://github.com/hantsy/spring-graphql-sample/blob/master/spring-graphql-rsocket-kotlin-co
I am also facing Can't resolve value (/listItems) : type mismatch error, expected type LIST got class kotlinx.coroutines.reactive.PublisherAsFlow
error
any workaround ?
https://github.com/xmlking/micro-apps/tree/main/services/spring-graphql-r2dbc
@xmlking Call yourflow.toList()
to convert it to a List
now.
checking graphql-kotlin-spring-server
spring project, looks like they support Flow
but this project compatible with official spring graphql project.
https://opensource.expediagroup.com/graphql-kotlin/docs/server/spring-server/spring-subscriptions
@xmlking I have tried it in my example project, but it has some limitations, the generic flow in in Query/Mutation and flow in Subscription can't be used at the same time.
I've created #954 to address the above. Note that since this issue was created, we've added annotated exception handler methods. Those are the preferred way to handle exceptions now, and would be covered by the change.
Add Kotlin Coroutines specific support.
Kotlin Coroutines support as alternative type of the
CompletableFuture
in DataLoaderSimilar to the existing ReactorDataLoader(internal class in the Spring GraphQl) etc.
CoroutinesBatchLoader
andCoroutinesMappedBatchLoader
variants.All Controller(Data Fetchers) fun supports Kotlin Coroutines
Currently I encountered an issue when returning a
Flow
in a query data fetching. For example,Define the following Graphql schema.
When executing the following query.
I got the exception like this.
Reproducing the issue: https://github.com/hantsy/spring-graphql-sample/blob/master/spring-graphql-rsocket-kotlin-co
Support Flow as Subscription return type
In a Kotlin Coroutines project, I would like use a Flow instead of Flux/Publisher as Subscription return type, that make my codes look smooth, no mixes of Reactor API and Kotlin Coroutines API.
Currently I have to convert it back to a Reactor Flux to make it work.
The example codes: https://github.com/hantsy/spring-graphql-sample/blob/master/spring-graphql-rsocket-kotlin-co/src/main/kotlin/com/example/demo/Services.kt#L92
Spring GraphQl has built-in
ReactorBatchLoader
internally. I think it is possible to use the same approach to getFlow
support as a Subscription type.Kotlin Coroutine variant of
DataFetcherExceptionResolver
Provides a variant to return
suspend
orFlow
instead of the Reactor APIs.