diff --git a/graphql-dgs-codegen-core/build.gradle b/graphql-dgs-codegen-core/build.gradle index 2fd1758d2..2792da501 100644 --- a/graphql-dgs-codegen-core/build.gradle +++ b/graphql-dgs-codegen-core/build.gradle @@ -41,6 +41,8 @@ dependencies { testImplementation 'com.google.guava:guava:33.4.+' testImplementation 'com.google.testing.compile:compile-testing:0.+' testImplementation 'org.jetbrains.kotlin:kotlin-compiler' + + integTestImplementation 'com.fasterxml.jackson.module:jackson-module-kotlin' } application { diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/Kotlin2CodeGenTest.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/Kotlin2CodeGenTest.kt index e5221c6f9..cbdcca3a4 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/Kotlin2CodeGenTest.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/Kotlin2CodeGenTest.kt @@ -18,11 +18,13 @@ package com.netflix.graphql.dgs.codegen +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.fail import org.junit.jupiter.api.Test import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.MethodSource +import java.net.URLClassLoader import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths @@ -35,6 +37,7 @@ import kotlin.io.path.readText class Kotlin2CodeGenTest { // set this to true to update all expected outputs instead of running tests private val updateExpected = false + private val objectMapper = jacksonObjectMapper() @ParameterizedTest @MethodSource("listTestsToRun") @@ -160,6 +163,109 @@ class Kotlin2CodeGenTest { assertCompilesKotlin(codeGenResult) } + @Test + fun `Jackson should deserialize input type with all optional fields without @JsonCreator annotation`() { + val schema = + """ + input PersonInput { + name: String + age: Int + email: String + } + """.trimIndent() + + val result = + CodeGen( + CodeGenConfig( + schemas = setOf(schema), + packageName = "com.netflix.test.alloptional", + language = Language.KOTLIN, + generateKotlinNullableClasses = true, + generateKotlinClosureProjections = true, + ), + ).generate() + + val buildDir = assertCompilesKotlin(result) + val classLoader = URLClassLoader(arrayOf(buildDir.toUri().toURL()), this.javaClass.classLoader) + val inputClass = classLoader.loadClass("com.netflix.test.alloptional.types.PersonInput") + + val json = """{"name": "John", "age": 30, "email": "john@example.com"}""" + val instance = objectMapper.readValue(json, inputClass) + assertThat(instance).isNotNull + } + + @Test + fun `Jackson should deserialize input type with required field`() { + val schema = + """ + input PersonInput { + name: String! + age: Int + email: String + } + """.trimIndent() + + val result = + CodeGen( + CodeGenConfig( + schemas = setOf(schema), + packageName = "com.netflix.test.withrequired", + language = Language.KOTLIN, + generateKotlinNullableClasses = true, + generateKotlinClosureProjections = true, + ), + ).generate() + + val buildDir = assertCompilesKotlin(result) + val classLoader = URLClassLoader(arrayOf(buildDir.toUri().toURL()), this.javaClass.classLoader) + val inputClass = classLoader.loadClass("com.netflix.test.withrequired.types.PersonInput") + + // Test runtime Jackson deserialization + val json = """{"name": "John", "age": 30, "email": "john@example.com"}""" + val instance = objectMapper.readValue(json, inputClass) + assertThat(instance).isNotNull + + val nameField = inputClass.getDeclaredField("name") + nameField.isAccessible = true + assertThat(nameField.get(instance)).isEqualTo("John") + } + + @Test + fun `Input type with explicit defaults should deserialize without conflicting creators error`() { + val schema = + """ + input PersonInput { + name: String! = "Unknown" + age: Int! = 0 + active: Boolean! = true + } + """.trimIndent() + + val result = + CodeGen( + CodeGenConfig( + schemas = setOf(schema), + packageName = "com.netflix.test.alldefaults", + language = Language.KOTLIN, + generateKotlinNullableClasses = true, + generateKotlinClosureProjections = true, + ), + ).generate() + + val buildDir = assertCompilesKotlin(result) + val classLoader = URLClassLoader(arrayOf(buildDir.toUri().toURL()), this.javaClass.classLoader) + val inputClass = classLoader.loadClass("com.netflix.test.alldefaults.types.PersonInput") + + val json = """{"name": "John", "age": 30, "active": false}""" + + val instance = objectMapper.readValue(json, inputClass) + assertThat(instance).isNotNull + + val nameField = inputClass.getDeclaredField("name") + nameField.isAccessible = true + assertThat(nameField.get(instance)).isEqualTo("John") + } + companion object { @Suppress("unused") @JvmStatic diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsForInputTypes/expected/types/PersonFilter.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsForInputTypes/expected/types/PersonFilter.kt index 6801151fc..43082678e 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsForInputTypes/expected/types/PersonFilter.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsForInputTypes/expected/types/PersonFilter.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.constantsForInputTypes.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -8,7 +7,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class PersonFilter @JsonCreator constructor( +public data class PersonFilter( @JsonProperty("email") public val email: String? = default("email", null), ) : GraphQLInput() { diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedInputTypes/expected/types/PersonFilter.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedInputTypes/expected/types/PersonFilter.kt index aecbfd920..bc09e48f1 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedInputTypes/expected/types/PersonFilter.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/constantsWithExtendedInputTypes/expected/types/PersonFilter.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.constantsWithExtendedInputTypes.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -9,7 +8,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class PersonFilter @JsonCreator constructor( +public data class PersonFilter( @JsonProperty("email") public val email: String? = default("email", null), @JsonProperty("birthYear") diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassDocs/expected/types/MovieFilter.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassDocs/expected/types/MovieFilter.kt index af689119e..20510a93e 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassDocs/expected/types/MovieFilter.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassDocs/expected/types/MovieFilter.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassDocs.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -13,7 +12,7 @@ import kotlin.collections.List * * It takes a title and such. */ -public data class MovieFilter @JsonCreator constructor( +public data class MovieFilter( @JsonProperty("titleFilter") public val titleFilter: String? = default("titleFilter", null), ) : GraphQLInput() { diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassFieldDocs/expected/types/MovieFilter.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassFieldDocs/expected/types/MovieFilter.kt index 3f6b14460..dfb71ce60 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassFieldDocs/expected/types/MovieFilter.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassFieldDocs/expected/types/MovieFilter.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.dataClassFieldDocs.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -8,7 +7,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class MovieFilter @JsonCreator constructor( +public data class MovieFilter( @JsonProperty("titleFilter") public val titleFilter: String? = default("titleFilter", null), ) : GraphQLInput() { diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/input/expected/types/MovieFilter.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/input/expected/types/MovieFilter.kt index cba3771ba..40d8099ab 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/input/expected/types/MovieFilter.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/input/expected/types/MovieFilter.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.input.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -8,7 +7,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class MovieFilter @JsonCreator constructor( +public data class MovieFilter( @JsonProperty("genre") public val genre: String? = default("genre", null), ) : GraphQLInput() { diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultBigDecimal/expected/types/OrderFilter.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultBigDecimal/expected/types/OrderFilter.kt index ee0e5dfb3..2355c61e3 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultBigDecimal/expected/types/OrderFilter.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultBigDecimal/expected/types/OrderFilter.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.inputWithDefaultBigDecimal.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import java.math.BigDecimal @@ -9,7 +8,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class OrderFilter @JsonCreator constructor( +public data class OrderFilter( @JsonProperty("min") public val min: BigDecimal = default("min", java.math.BigDecimal("1.1")), @JsonProperty("avg") diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultCurrency/expected/types/OrderFilter.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultCurrency/expected/types/OrderFilter.kt index 45066fa8e..0e92509ab 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultCurrency/expected/types/OrderFilter.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultCurrency/expected/types/OrderFilter.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.inputWithDefaultCurrency.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import java.util.Currency @@ -9,7 +8,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class OrderFilter @JsonCreator constructor( +public data class OrderFilter( @JsonProperty("value") public val `value`: Currency = default("value", java.util.Currency.getInstance("USD")), diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultEnumValueForArray/expected/types/SomeType.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultEnumValueForArray/expected/types/SomeType.kt index 36baf9c11..3e87030e1 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultEnumValueForArray/expected/types/SomeType.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultEnumValueForArray/expected/types/SomeType.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.inputWithDefaultEnumValueForArray.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -8,7 +7,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class SomeType @JsonCreator constructor( +public data class SomeType( @JsonProperty("colors") public val colors: List? = default?>("colors", listOf(com.netflix.graphql.dgs.codegen.cases.inputWithDefaultEnumValueForArray.expected.types.Color.red)), diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultIntValueForArray/expected/types/SomeType.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultIntValueForArray/expected/types/SomeType.kt index a4c0cdc80..d7ce650b3 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultIntValueForArray/expected/types/SomeType.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultIntValueForArray/expected/types/SomeType.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.inputWithDefaultIntValueForArray.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -9,7 +8,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class SomeType @JsonCreator constructor( +public data class SomeType( @JsonProperty("numbers") public val numbers: List? = default?>("numbers", listOf(1, 2, 3)), ) : GraphQLInput() { diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultStringValueForArray/expected/types/SomeType.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultStringValueForArray/expected/types/SomeType.kt index 6c6978d14..14d230c34 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultStringValueForArray/expected/types/SomeType.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultStringValueForArray/expected/types/SomeType.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.inputWithDefaultStringValueForArray.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -8,7 +7,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class SomeType @JsonCreator constructor( +public data class SomeType( @JsonProperty("names") public val names: List? = default?>("names", listOf("A", "B")), ) : GraphQLInput() { diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForArray/expected/types/SomeType.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForArray/expected/types/SomeType.kt index c20acb7f0..acd9a9fe7 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForArray/expected/types/SomeType.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForArray/expected/types/SomeType.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.inputWithDefaultValueForArray.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -8,7 +7,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class SomeType @JsonCreator constructor( +public data class SomeType( @JsonProperty("names") public val names: List? = default?>("names", emptyList()), ) : GraphQLInput() { diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForEnum/expected/types/ColorFilter.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForEnum/expected/types/ColorFilter.kt index dec9aa4db..9d45ac230 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForEnum/expected/types/ColorFilter.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForEnum/expected/types/ColorFilter.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.inputWithDefaultValueForEnum.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -8,7 +7,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class ColorFilter @JsonCreator constructor( +public data class ColorFilter( @JsonProperty("color") public val color: Color? = default("color", com.netflix.graphql.dgs.codegen.cases.inputWithDefaultValueForEnum.expected.types.Color.red), diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForNonNullableFields/expected/types/Car.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForNonNullableFields/expected/types/Car.kt index 40e6dc559..20ebbe688 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForNonNullableFields/expected/types/Car.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForNonNullableFields/expected/types/Car.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.inputWithDefaultValueForNonNullableFields.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -8,7 +7,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class Car @JsonCreator constructor( +public data class Car( @JsonProperty("brand") public val brand: String = default("brand", "BMW"), ) : GraphQLInput() { diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForNonNullableFields/expected/types/Person.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForNonNullableFields/expected/types/Person.kt index 2716c81c9..505f66437 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForNonNullableFields/expected/types/Person.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForNonNullableFields/expected/types/Person.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.inputWithDefaultValueForNonNullableFields.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -10,7 +9,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class Person @JsonCreator constructor( +public data class Person( @JsonProperty("name") public val name: String = default("name", "Damian"), @JsonProperty("age") diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForObject/expected/types/Car.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForObject/expected/types/Car.kt index 73ee1f02b..f48435c8b 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForObject/expected/types/Car.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForObject/expected/types/Car.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.inputWithDefaultValueForObject.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -8,7 +7,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class Car @JsonCreator constructor( +public data class Car( @JsonProperty("brand") public val brand: String = default("brand", "BMW"), ) : GraphQLInput() { diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForObject/expected/types/MovieFilter.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForObject/expected/types/MovieFilter.kt index 938828e15..d764c94a1 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForObject/expected/types/MovieFilter.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForObject/expected/types/MovieFilter.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.inputWithDefaultValueForObject.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -8,7 +7,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class MovieFilter @JsonCreator constructor( +public data class MovieFilter( @JsonProperty("director") public val director: Person? = default("director", com.netflix.graphql.dgs.codegen.cases.inputWithDefaultValueForObject.expected.types.Person(name diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForObject/expected/types/Person.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForObject/expected/types/Person.kt index c6197a76a..d09368d28 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForObject/expected/types/Person.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithDefaultValueForObject/expected/types/Person.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.inputWithDefaultValueForObject.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -9,7 +8,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class Person @JsonCreator constructor( +public data class Person( @JsonProperty("name") public val name: String? = default("name", "John"), @JsonProperty("age") diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithExtendedType/expected/types/MovieFilter.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithExtendedType/expected/types/MovieFilter.kt index d90e75e76..effc22817 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithExtendedType/expected/types/MovieFilter.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithExtendedType/expected/types/MovieFilter.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.inputWithExtendedType.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -9,7 +8,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class MovieFilter @JsonCreator constructor( +public data class MovieFilter( @JsonProperty("genre") public val genre: String? = default("genre", null), @JsonProperty("releaseYear") diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithReservedWord/expected/types/SampleInput.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithReservedWord/expected/types/SampleInput.kt index f180df53e..971eaa0fc 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithReservedWord/expected/types/SampleInput.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/inputWithReservedWord/expected/types/SampleInput.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.inputWithReservedWord.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -8,7 +7,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class SampleInput @JsonCreator constructor( +public data class SampleInput( @JsonProperty("return") public val `return`: String, ) : GraphQLInput() { diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithNestedInputs/expected/types/I1.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithNestedInputs/expected/types/I1.kt index 0fa51259c..bbd778aa6 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithNestedInputs/expected/types/I1.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithNestedInputs/expected/types/I1.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.projectionWithNestedInputs.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -8,7 +7,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class I1 @JsonCreator constructor( +public data class I1( @JsonProperty("arg1") public val arg1: I1? = default("arg1", null), @JsonProperty("arg2") diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithNestedInputs/expected/types/I2.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithNestedInputs/expected/types/I2.kt index 5bd436be4..a7ad40060 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithNestedInputs/expected/types/I2.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithNestedInputs/expected/types/I2.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.projectionWithNestedInputs.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -8,7 +7,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class I2 @JsonCreator constructor( +public data class I2( @JsonProperty("arg1") public val arg1: String? = default("arg1", null), @JsonProperty("arg2") diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithPrimitiveAndArgs/expected/types/I.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithPrimitiveAndArgs/expected/types/I.kt index b31a30606..ba312d96c 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithPrimitiveAndArgs/expected/types/I.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithPrimitiveAndArgs/expected/types/I.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.projectionWithPrimitiveAndArgs.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -8,7 +7,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class I @JsonCreator constructor( +public data class I( @JsonProperty("arg") public val arg: String? = default("arg", null), ) : GraphQLInput() { diff --git a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithTypeAndArgs/expected/types/I.kt b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithTypeAndArgs/expected/types/I.kt index 736050e38..cb3269b07 100644 --- a/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithTypeAndArgs/expected/types/I.kt +++ b/graphql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/cases/projectionWithTypeAndArgs/expected/types/I.kt @@ -1,6 +1,5 @@ package com.netflix.graphql.dgs.codegen.cases.projectionWithTypeAndArgs.expected.types -import com.fasterxml.jackson.`annotation`.JsonCreator import com.fasterxml.jackson.`annotation`.JsonProperty import com.netflix.graphql.dgs.codegen.GraphQLInput import kotlin.Any @@ -8,7 +7,7 @@ import kotlin.Pair import kotlin.String import kotlin.collections.List -public data class I @JsonCreator constructor( +public data class I( @JsonProperty("arg") public val arg: String? = default("arg", null), ) : GraphQLInput() { diff --git a/graphql-dgs-codegen-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/generators/kotlin2/GenerateKotlin2InputTypes.kt b/graphql-dgs-codegen-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/generators/kotlin2/GenerateKotlin2InputTypes.kt index 8280c9c57..741f43472 100644 --- a/graphql-dgs-codegen-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/generators/kotlin2/GenerateKotlin2InputTypes.kt +++ b/graphql-dgs-codegen-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/generators/kotlin2/GenerateKotlin2InputTypes.kt @@ -18,7 +18,6 @@ package com.netflix.graphql.dgs.codegen.generators.kotlin2 -import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.netflix.graphql.dgs.codegen.CodeGenConfig import com.netflix.graphql.dgs.codegen.GraphQLInput @@ -89,7 +88,6 @@ fun generateKotlin2InputTypes( .primaryConstructor( FunSpec .constructorBuilder() - .addAnnotation(JsonCreator::class) .addParameters( fields.map { field -> val type = type(field)