diff --git a/client/model-builder/pom.xml b/client/model-builder/pom.xml
index 527d159a1..32158e3ae 100644
--- a/client/model-builder/pom.xml
+++ b/client/model-builder/pom.xml
@@ -50,6 +50,12 @@
smallrye-graphql-api
test
+
+ org.jetbrains.kotlin
+ kotlin-reflect
+ ${version.kotlin}
+ test
+
@@ -61,6 +67,40 @@
true
+
+ kotlin-maven-plugin
+ org.jetbrains.kotlin
+ ${version.kotlin.compiler}
+
+
+ test-compile
+
+ test-compile
+
+
+
+ ${project.basedir}/src/test/kotlin
+
+
+
+
+
+
+ all-open
+
+
+ -java-parameters
+
+
+
+
+
+ org.jetbrains.kotlin
+ kotlin-maven-allopen
+ ${version.kotlin.compiler}
+
+
+
\ No newline at end of file
diff --git a/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/ParameterModel.java b/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/ParameterModel.java
index be3b24204..e1c4753ce 100644
--- a/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/ParameterModel.java
+++ b/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/ParameterModel.java
@@ -13,6 +13,7 @@
import org.jboss.jandex.MethodParameterInfo;
+import io.smallrye.graphql.client.model.Annotations;
import io.smallrye.graphql.client.model.Scalars;
import io.smallrye.graphql.client.typesafe.api.Header;
@@ -179,11 +180,11 @@ private String graphQlInputTypeName(TypeModel type) {
/**
* Adds an optional exclamation mark to the GraphQL input type name based on nullability.
*
- * @param type The {@link TypeModel} representing the type of the parameter.
* @return An optional exclamation mark.
*/
private String optionalExclamationMark(TypeModel type) {
- return type.isNonNull() ? "!" : "";
+ // for some reason KOTLIN_NOT_NULL is not applied on type, but on parameter
+ return (parameter.hasAnnotation(Annotations.KOTLIN_NOT_NULL) || type.isNonNull()) ? "!" : "";
}
/**
diff --git a/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/TypeModel.java b/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/TypeModel.java
index 619106feb..85a26d707 100644
--- a/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/TypeModel.java
+++ b/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/TypeModel.java
@@ -141,7 +141,8 @@ public TypeModel getMapValueType() {
public boolean isNonNull() {
return isPrimitive() ||
type.hasAnnotation(Annotations.NON_NULL) ||
- type.hasAnnotation(Annotations.JAKARTA_NON_NULL);
+ type.hasAnnotation(Annotations.JAKARTA_NON_NULL)
+ || type.hasAnnotation(Annotations.KOTLIN_NOT_NULL);
}
/**
diff --git a/client/model-builder/src/test/java/io/smallrye/graphql/client/model/ClientModelBuilderTest.java b/client/model-builder/src/test/java/io/smallrye/graphql/client/model/ClientModelBuilderTest.java
index 649187fb7..99291df96 100644
--- a/client/model-builder/src/test/java/io/smallrye/graphql/client/model/ClientModelBuilderTest.java
+++ b/client/model-builder/src/test/java/io/smallrye/graphql/client/model/ClientModelBuilderTest.java
@@ -40,7 +40,7 @@ interface ScalarClientApi {
}
@Test
- void sclarClientModelTest() throws IOException {
+ void scalarClientModelTest() throws IOException {
String configKey = "scalar";
ClientModels clientModels = ClientModelBuilder.build(Index.of(ScalarClientApi.class));
assertNotNull(clientModels.getClientModelByConfigKey(configKey));
diff --git a/client/model-builder/src/test/kotlin/ClientModelBuilderKotlinTest.kt b/client/model-builder/src/test/kotlin/ClientModelBuilderKotlinTest.kt
new file mode 100644
index 000000000..0066d6a9f
--- /dev/null
+++ b/client/model-builder/src/test/kotlin/ClientModelBuilderKotlinTest.kt
@@ -0,0 +1,43 @@
+package io.smallrye.graphql.client.model
+
+import io.smallrye.graphql.client.typesafe.api.GraphQLClientApi
+import org.eclipse.microprofile.graphql.Query
+import org.jboss.jandex.Index
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Assertions.assertNotNull
+import org.junit.jupiter.api.Test
+
+class ClientModelBuilderKotlinTest {
+ @GraphQLClientApi(configKey = "some-client")
+ interface ClientApi {
+ @Query
+ fun returnNonNullFloat(someFloat: Float): Float
+
+ @Query
+ fun returnNullableString(someString: String?): String?
+
+ @Query
+ fun returnList(list: List): String
+
+ // fixme: nullability is bit inconsistent from kotlin
+
+ }
+
+ @Test
+ fun basicClientModelTest() {
+ val configKey = "some-client"
+ val clientModels = ClientModelBuilder.build(Index.of(ClientApi::class.java))
+ assertNotNull(clientModels)
+ val clientModel = clientModels.getClientModelByConfigKey(configKey)
+ assertNotNull(clientModel)
+ assertEquals(3, clientModel.operationMap.size)
+ assertOperation(clientModel, MethodKey("returnNonNullFloat", arrayOf(Float::class.java)), "query returnNonNullFloat(\$someFloat: Float!) { returnNonNullFloat(someFloat: \$someFloat) }")
+ assertOperation(clientModel, MethodKey("returnNullableString", arrayOf(String::class.java)), "query returnNullableString(\$someString: String) { returnNullableString(someString: \$someString) }")
+ assertOperation(clientModel, MethodKey("returnList", arrayOf(List::class.java)), "query returnList(\$list: [String!]!) { returnList(list: \$list) }")
+ }
+
+ private fun assertOperation(clientModel: ClientModel, methodKey: MethodKey, expectedQuery: String) {
+ val actualQuery = clientModel.operationMap[methodKey]
+ assertEquals(expectedQuery, actualQuery)
+ }
+}
\ No newline at end of file
diff --git a/common/schema-builder/pom.xml b/common/schema-builder/pom.xml
index 833f92837..19a0da7c0 100644
--- a/common/schema-builder/pom.xml
+++ b/common/schema-builder/pom.xml
@@ -11,7 +11,7 @@
smallrye-graphql-schema-builder
SmallRye: GraphQL Common :: Schema Builder
Creates the model from a Jandex index
-
+
@@ -40,7 +40,7 @@
org.jetbrains.kotlin
kotlin-metadata-jvm
- ${version.kotlin.metadata.jvm}
+ ${version.kotlin}
diff --git a/pom.xml b/pom.xml
index 98ce9d908..09705dcab 100644
--- a/pom.xml
+++ b/pom.xml
@@ -62,7 +62,7 @@
17
17
17
- 2.1.0
+ 2.1.10
1.12.0
2.1.0