Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# KGraphQL version
version=0.17.11
version=0.17.12-SNAPSHOT

# Dependencies
coroutine_version=1.5.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T : Any>(val kClass: KClass<T>) : DepreciableItemDSL() {
class InputValueDSL<T : Any>(val kClass: KClass<T>, val kType: KType? = null) : DepreciableItemDSL() {

lateinit var name : String

Expand All @@ -17,6 +18,7 @@ class InputValueDSL<T : Any>(val kClass: KClass<T>) : DepreciableItemDSL() {
defaultValue = defaultValue,
isDeprecated = isDeprecated,
description = description,
deprecationReason = deprecationReason
deprecationReason = deprecationReason,
kType = kType
)
}
}
Original file line number Diff line number Diff line change
@@ -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<InputValueDSL<*>>()


fun <T : Any> arg(kClass: KClass<T>, block : InputValueDSL<T>.() -> Unit){
inputValues.add(InputValueDSL(kClass).apply(block))
fun <T : Any> arg(kClass: KClass<T>, kType: KType? = null, block : InputValueDSL<T>.() -> Unit){
inputValues.add(InputValueDSL(kClass, kType).apply(block))
}

@OptIn(ExperimentalStdlibApi::class)
inline fun <reified T : Any> arg(noinline block : InputValueDSL<T>.() -> Unit){
arg(T::class, block)
arg(T::class, typeOf<T>(), block)
}

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.apurebase.kgraphql.schema.model

import kotlin.reflect.KClass
import kotlin.reflect.KType


class InputValueDef<T : Any>(
Expand All @@ -9,5 +10,6 @@ class InputValueDef<T : Any>(
val defaultValue : T? = null,
override val isDeprecated: Boolean = false,
override val description: String? = null,
override val deprecationReason: String? = null
) : DescribedDef, Depreciable
override val deprecationReason: String? = null,
val kType : KType? = null
) : DescribedDef, Depreciable
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down