Closed inaiat closed 3 years ago
Hi, thanks for the report.
There is only one change (#143) in version 0.17.8
. So you can just downgrade to 0.17.7
and I will make sure that the next version will have a fix for this.
Ok @jeggy.
Thank you.
Hi @inaiat, I'm trying to reproduce this so I can fix it correctly, but I'm not able to reproduce this. Could you help me a bit and provide an example of the setup you had which caused this? Maybe a simple query/resolver definition?
@jeggy it looks like the problem is with default argument of resolver. Exemple:
query("slots") {
resolver {
limit: Int,
tags: List<String> ->
getSlots(limit = limit, tags = tags)
}.withArgs {
arg<Int> { name = "limit"; defaultValue = 7 }
arg<List<String>> { name = "tags"; defaultValue = emptyList() }
}
}
When I remove arg<List
Full code:
package com.example
import com.apurebase.kgraphql.GraphqlRequest
import com.apurebase.kgraphql.KGraphQL
import io.ktor.application.*
import io.ktor.http.*
import io.ktor.request.*
import io.ktor.response.*
import io.ktor.routing.*
import kotlinx.serialization.Contextual
import kotlinx.serialization.Serializable
import java.time.LocalDate
fun main(args: Array<String>) = io.ktor.server.netty.EngineMain.main(args)
fun Application.module() {
routing {
post("/graphql") {
val request = call.receive<GraphqlRequest>()
val result = schema.execute(request.query, request.variables.toString())
call.respondText(result, contentType = ContentType.Application.Json)
}
}
}
val schema = KGraphQL.schema {
stringScalar<LocalDate> {
serialize = { date -> date.toString() }
deserialize = { dateString -> LocalDate.parse(dateString) }
}
query("slots") {
resolver {
limit: Int,
tags: List<String> ->
getSlots(limit = limit, tags = tags)
}.withArgs {
arg<Int> { name = "limit"; defaultValue = 7 }
arg<List<String>> { name = "tags"; defaultValue = emptyList() }
}
}
}
fun getSlots(limit: Int, tags: List<String>): List<Agenda> =
listOf(
Agenda(date = LocalDate.now(), slots = listOf(Slots(1)), hasSlotsAvailable = true)
)
@Serializable
data class Agenda(
@Contextual
val date: LocalDate,
val slots: List<Slots>,
val hasSlotsAvailable: Boolean
)
@Serializable
data class Slots(
val hour: Int
)
Thanks!
0.17.9
has been released and this issue should no longer exist.
Hi. After updating to 0.17.18 #143 , I get the error below at app start:
Caused by: java.util.NoSuchElementException: KType kotlin.collections.List<*> has no type arguments at com.apurebase.kgraphql.ExtensionsKt.getIterableElementType(Extensions.kt:30) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handleCollectionType(SchemaCompilation.kt:186) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handlePossiblyWrappedType(SchemaCompilation.kt:164) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handleInputValues(SchemaCompilation.kt:337) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handleOperation(SchemaCompilation.kt:151) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handleObjectType(SchemaCompilation.kt:275) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handleRawType(SchemaCompilation.kt:226) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handleSimpleType(SchemaCompilation.kt:196) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handlePossiblyWrappedType(SchemaCompilation.kt:174) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handleKotlinProperty(SchemaCompilation.kt:373) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handleObjectType(SchemaCompilation.kt:267) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.perform(SchemaCompilation.kt:61)
My app works without any problem with 0.17.17 and Ktor 1.5.4
I Appreciate your help. Thank you.
The full stacktrace:
Caused by: java.lang.reflect.InvocationTargetException: null at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481) at org.koin.experimental.builder.InstanceBuilderKt.createInstance(InstanceBuilder.kt:49) at com.volanty.discovery.graphql.config.AppConfigKt$configModule$1$$special$$inlined$single$7.invoke(ModuleExt.kt:102) at com.volanty.discovery.graphql.config.AppConfigKt$configModule$1$$special$$inlined$single$7.invoke(ModuleExt.kt) at org.koin.core.instance.InstanceFactory.create(InstanceFactory.kt:54) ... 73 common frames omitted Caused by: java.util.NoSuchElementException: KType kotlin.collections.List<*> has no type arguments at com.apurebase.kgraphql.ExtensionsKt.getIterableElementType(Extensions.kt:30) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handleCollectionType(SchemaCompilation.kt:186) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handlePossiblyWrappedType(SchemaCompilation.kt:164) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handleInputValues(SchemaCompilation.kt:337) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handleOperation(SchemaCompilation.kt:151) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handleObjectType(SchemaCompilation.kt:275) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handleRawType(SchemaCompilation.kt:226) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handleSimpleType(SchemaCompilation.kt:196) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handlePossiblyWrappedType(SchemaCompilation.kt:174) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handleKotlinProperty(SchemaCompilation.kt:373) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.handleObjectType(SchemaCompilation.kt:267) at com.apurebase.kgraphql.schema.structure.SchemaCompilation.perform(SchemaCompilation.kt:61) at com.apurebase.kgraphql.schema.dsl.SchemaBuilder$build$1.invokeSuspend(SchemaBuilder.kt:32) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:277) at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:86) at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:61) at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source) at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt) at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source) at com.apurebase.kgraphql.schema.dsl.SchemaBuilder.build(SchemaBuilder.kt:31) at com.apurebase.kgraphql.KGraphQL$Companion.schema(KGraphQL.kt:12) at com.volanty.discovery.graphql.service.GraphQLService.<init>(GraphQLService.kt:42) ... 82 common frames omitted