From b96e3d8cdfb210c92f005176394d3a24367ac9fa Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 29 Jul 2021 16:51:52 +0200 Subject: [PATCH 1/4] Optional ktype in inputdef to override input type --- .../com/apurebase/kgraphql/schema/model/InputValueDef.kt | 6 ++++-- .../kgraphql/schema/structure/SchemaCompilation.kt | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) 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) } } From 7c69cf6615d1f36405e2a666a4c7a607f28a9089 Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 29 Jul 2021 16:57:02 +0200 Subject: [PATCH 2/4] Disable signing --- kgraphql/build.gradle.kts | 94 +++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/kgraphql/build.gradle.kts b/kgraphql/build.gradle.kts index e420407d..eb2a7d73 100644 --- a/kgraphql/build.gradle.kts +++ b/kgraphql/build.gradle.kts @@ -76,50 +76,50 @@ val dokkaJar by tasks.creating(Jar::class) { from(tasks.dokkaHtml) } -publishing { - publications { - create("maven") { - artifactId = project.name - from(components["java"]) - artifact(sourcesJar) - artifact(dokkaJar) - pom { - name.set("KGraphQL") - description.set("KGraphQL is a Kotlin implementation of GraphQL. It provides a rich DSL to set up the GraphQL schema.") - url.set("https://kgraphql.io/") - organization { - name.set("aPureBase") - url.set("http://apurebase.com/") - } - licenses { - license { - name.set("MIT License") - url.set("https://github.com/aPureBase/KGraphQL/blob/main/LICENSE.md") - } - } - developers { - developer { - id.set("jeggy") - name.set("Jógvan Olsen") - email.set("jol@apurebase.com") - } - } - scm { - connection.set("scm:git:https://github.com/aPureBase/KGraphQL.git") - developerConnection.set("scm:git:https://github.com/aPureBase/KGraphQL.git") - url.set("https://github.com/aPureBase/KGraphQL/") - tag.set("HEAD") - } - } - } - } -} - -signing { - isRequired = isReleaseVersion - useInMemoryPgpKeys( - System.getenv("ORG_GRADLE_PROJECT_signingKey"), - System.getenv("ORG_GRADLE_PROJECT_signingPassword") - ) - sign(publishing.publications["maven"]) -} +//publishing { +// publications { +// create("maven") { +// artifactId = project.name +// from(components["java"]) +// artifact(sourcesJar) +// artifact(dokkaJar) +// pom { +// name.set("KGraphQL") +// description.set("KGraphQL is a Kotlin implementation of GraphQL. It provides a rich DSL to set up the GraphQL schema.") +// url.set("https://kgraphql.io/") +// organization { +// name.set("aPureBase") +// url.set("http://apurebase.com/") +// } +// licenses { +// license { +// name.set("MIT License") +// url.set("https://github.com/aPureBase/KGraphQL/blob/main/LICENSE.md") +// } +// } +// developers { +// developer { +// id.set("jeggy") +// name.set("Jógvan Olsen") +// email.set("jol@apurebase.com") +// } +// } +// scm { +// connection.set("scm:git:https://github.com/aPureBase/KGraphQL.git") +// developerConnection.set("scm:git:https://github.com/aPureBase/KGraphQL.git") +// url.set("https://github.com/aPureBase/KGraphQL/") +// tag.set("HEAD") +// } +// } +// } +// } +//} +// +//signing { +// isRequired = isReleaseVersion +// useInMemoryPgpKeys( +// System.getenv("ORG_GRADLE_PROJECT_signingKey"), +// System.getenv("ORG_GRADLE_PROJECT_signingPassword") +// ) +// sign(publishing.publications["maven"]) +//} From 9eeddc203f303a39d0ffe7115427736fb4c13bba Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 29 Jul 2021 16:59:53 +0200 Subject: [PATCH 3/4] Snapshot version --- gradle.properties | 2 +- kgraphql/build.gradle.kts | 94 +++++++++++++++++++-------------------- 2 files changed, 48 insertions(+), 48 deletions(-) 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/build.gradle.kts b/kgraphql/build.gradle.kts index eb2a7d73..e420407d 100644 --- a/kgraphql/build.gradle.kts +++ b/kgraphql/build.gradle.kts @@ -76,50 +76,50 @@ val dokkaJar by tasks.creating(Jar::class) { from(tasks.dokkaHtml) } -//publishing { -// publications { -// create("maven") { -// artifactId = project.name -// from(components["java"]) -// artifact(sourcesJar) -// artifact(dokkaJar) -// pom { -// name.set("KGraphQL") -// description.set("KGraphQL is a Kotlin implementation of GraphQL. It provides a rich DSL to set up the GraphQL schema.") -// url.set("https://kgraphql.io/") -// organization { -// name.set("aPureBase") -// url.set("http://apurebase.com/") -// } -// licenses { -// license { -// name.set("MIT License") -// url.set("https://github.com/aPureBase/KGraphQL/blob/main/LICENSE.md") -// } -// } -// developers { -// developer { -// id.set("jeggy") -// name.set("Jógvan Olsen") -// email.set("jol@apurebase.com") -// } -// } -// scm { -// connection.set("scm:git:https://github.com/aPureBase/KGraphQL.git") -// developerConnection.set("scm:git:https://github.com/aPureBase/KGraphQL.git") -// url.set("https://github.com/aPureBase/KGraphQL/") -// tag.set("HEAD") -// } -// } -// } -// } -//} -// -//signing { -// isRequired = isReleaseVersion -// useInMemoryPgpKeys( -// System.getenv("ORG_GRADLE_PROJECT_signingKey"), -// System.getenv("ORG_GRADLE_PROJECT_signingPassword") -// ) -// sign(publishing.publications["maven"]) -//} +publishing { + publications { + create("maven") { + artifactId = project.name + from(components["java"]) + artifact(sourcesJar) + artifact(dokkaJar) + pom { + name.set("KGraphQL") + description.set("KGraphQL is a Kotlin implementation of GraphQL. It provides a rich DSL to set up the GraphQL schema.") + url.set("https://kgraphql.io/") + organization { + name.set("aPureBase") + url.set("http://apurebase.com/") + } + licenses { + license { + name.set("MIT License") + url.set("https://github.com/aPureBase/KGraphQL/blob/main/LICENSE.md") + } + } + developers { + developer { + id.set("jeggy") + name.set("Jógvan Olsen") + email.set("jol@apurebase.com") + } + } + scm { + connection.set("scm:git:https://github.com/aPureBase/KGraphQL.git") + developerConnection.set("scm:git:https://github.com/aPureBase/KGraphQL.git") + url.set("https://github.com/aPureBase/KGraphQL/") + tag.set("HEAD") + } + } + } + } +} + +signing { + isRequired = isReleaseVersion + useInMemoryPgpKeys( + System.getenv("ORG_GRADLE_PROJECT_signingKey"), + System.getenv("ORG_GRADLE_PROJECT_signingPassword") + ) + sign(publishing.publications["maven"]) +} From 68d6c235e5e92b5a4106ed6f09e6a6a3826af46a Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 29 Jul 2021 17:06:17 +0200 Subject: [PATCH 4/4] Automatic setting ktype from InputValuesDSL --- .../kgraphql/schema/dsl/types/InputValueDSL.kt | 8 +++++--- .../kgraphql/schema/dsl/types/InputValuesDSL.kt | 12 +++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) 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 +}