diff --git a/gradle.properties b/gradle.properties index dcd61d42..5c097d8b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # KGraphQL version -version=0.17.11 +version=0.17.12-SNAPSHOT # Dependencies coroutine_version=1.5.0 diff --git a/kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/dsl/types/InputValueDSL.kt b/kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/dsl/types/InputValueDSL.kt index f4deac35..bbdd2e37 100644 --- a/kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/dsl/types/InputValueDSL.kt +++ b/kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/dsl/types/InputValueDSL.kt @@ -3,9 +3,10 @@ package com.apurebase.kgraphql.schema.dsl.types import com.apurebase.kgraphql.schema.dsl.DepreciableItemDSL import com.apurebase.kgraphql.schema.model.InputValueDef import kotlin.reflect.KClass +import kotlin.reflect.KType -class InputValueDSL(val kClass: KClass) : DepreciableItemDSL() { +class InputValueDSL(val kClass: KClass, val kType: KType? = null) : DepreciableItemDSL() { lateinit var name : String @@ -17,6 +18,7 @@ class InputValueDSL(val kClass: KClass) : DepreciableItemDSL() { defaultValue = defaultValue, isDeprecated = isDeprecated, description = description, - deprecationReason = deprecationReason + deprecationReason = deprecationReason, + kType = kType ) -} \ No newline at end of file +} diff --git a/kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/dsl/types/InputValuesDSL.kt b/kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/dsl/types/InputValuesDSL.kt index a8b7c4e8..4b8b76a0 100644 --- a/kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/dsl/types/InputValuesDSL.kt +++ b/kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/dsl/types/InputValuesDSL.kt @@ -1,19 +1,21 @@ package com.apurebase.kgraphql.schema.dsl.types import kotlin.reflect.KClass +import kotlin.reflect.KType +import kotlin.reflect.typeOf class InputValuesDSL { val inputValues = mutableListOf>() - - fun arg(kClass: KClass, block : InputValueDSL.() -> Unit){ - inputValues.add(InputValueDSL(kClass).apply(block)) + fun arg(kClass: KClass, kType: KType? = null, block : InputValueDSL.() -> Unit){ + inputValues.add(InputValueDSL(kClass, kType).apply(block)) } + @OptIn(ExperimentalStdlibApi::class) inline fun arg(noinline block : InputValueDSL.() -> Unit){ - arg(T::class, block) + arg(T::class, typeOf(), block) } -} \ No newline at end of file +} diff --git a/kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/model/InputValueDef.kt b/kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/model/InputValueDef.kt index 6cb0abd8..3144d8fb 100644 --- a/kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/model/InputValueDef.kt +++ b/kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/model/InputValueDef.kt @@ -1,6 +1,7 @@ package com.apurebase.kgraphql.schema.model import kotlin.reflect.KClass +import kotlin.reflect.KType class InputValueDef( @@ -9,5 +10,6 @@ class InputValueDef( val defaultValue : T? = null, override val isDeprecated: Boolean = false, override val description: String? = null, - override val deprecationReason: String? = null -) : DescribedDef, Depreciable \ No newline at end of file + override val deprecationReason: String? = null, + val kType : KType? = null +) : DescribedDef, Depreciable diff --git a/kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/structure/SchemaCompilation.kt b/kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/structure/SchemaCompilation.kt index 665d6d00..3e898aab 100644 --- a/kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/structure/SchemaCompilation.kt +++ b/kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/structure/SchemaCompilation.kt @@ -332,8 +332,9 @@ class SchemaCompilation( } return operation.argumentsDescriptor.map { (name, kType) -> - val kqlInput = inputValues.find { it.name == name } ?: InputValueDef(kType.jvmErasure, name) - val inputType = handlePossiblyWrappedType(kType, TypeCategory.INPUT) + val inputValue = inputValues.find { it.name == name } + val kqlInput = inputValue ?: InputValueDef(kType.jvmErasure, name) + val inputType = handlePossiblyWrappedType(inputValue?.kType ?: kType, TypeCategory.INPUT) InputValue(kqlInput, inputType) } }