dgs-framework
dgs-framework copied to clipboard
DgsQuery that returns a Kotlin Flow failed to execute
In these days, I tried to update Dgs/Kotlin Coroutines example, when I updated the QueryTests.
And run it, and got the following exception.
Can't resolve value (/allPosts) : type mismatch error, expected type LIST got class kotlinx.coroutines.flow.FlowKt__BuildersKt$flowOf$$inlined$unsafeFlow$1
The query component is:
@DgsComponent
class PostsDataFetcher(val postService: PostService) {
@DgsQuery
fun allPosts(): Flow<Post> = postService.allPosts()
...
}
The testing codes is here, https://github.com/hantsy/spring-graphql-sample/blob/master/dgs-kotlin-co/src/test/kotlin/com/example/demo/QueryTests.kt
I got the similar errors when executing the allPosts query in the /graphiql web interfaces.
{
"errors": [
{
"message": "Can't resolve value (/allPosts) : type mismatch error, expected type LIST",
"path": [
"allPosts"
],
"extensions": {
"classification": "DataFetchingException"
}
}
],
"data": null
}
Originally posted by @hantsy in https://github.com/Netflix/dgs-framework/discussions/1075
I'm guessing it is latest 4.x or 5.x?
I am using 4.10.4, https://github.com/hantsy/spring-graphql-sample/blob/master/dgs-kotlin-co/build.gradle.kts#L23
I remember the basic Kotlin Coroutines support was already added https://github.com/Netflix/dgs-framework/issues/413
Updated to 5.0.1, still failed.
5.0.2 failed
This hasn't been addressed yet. We will look at this for the next release.
Any update for this? The Spring official GraphQL module has the same problem.
Not yet @hantsy , hopefully soon we can have a better answer.