-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix escaping of reserved words in kotlin2 generated data types (#623)
* Fix escaping of reserved words in kotlin2 generated data types * Add distribution to CI build
- Loading branch information
1 parent
de5edfd
commit e048106
Showing
8 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...lin/com/netflix/graphql/dgs/codegen/cases/dataClassWithReservedWord/expected/DgsClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithReservedWord.expected | ||
|
||
public object DgsClient |
11 changes: 11 additions & 0 deletions
11
.../com/netflix/graphql/dgs/codegen/cases/dataClassWithReservedWord/expected/DgsConstants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithReservedWord.expected | ||
|
||
import kotlin.String | ||
|
||
public object DgsConstants { | ||
public object SAMPLETYPE { | ||
public const val TYPE_NAME: String = "SampleType" | ||
|
||
public const val Return: String = "return" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...aphql/dgs/codegen/cases/dataClassWithReservedWord/expected/client/SampleTypeProjection.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithReservedWord.expected.client | ||
|
||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
|
||
public class SampleTypeProjection : GraphQLProjection() { | ||
public val `return`: SampleTypeProjection | ||
get() { | ||
field("return") | ||
return this | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
.../netflix/graphql/dgs/codegen/cases/dataClassWithReservedWord/expected/types/SampleType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithReservedWord.expected.types | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonIgnoreProperties | ||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import com.fasterxml.jackson.`annotation`.JsonTypeInfo | ||
import com.fasterxml.jackson.databind.`annotation`.JsonDeserialize | ||
import com.fasterxml.jackson.databind.`annotation`.JsonPOJOBuilder | ||
import java.lang.IllegalStateException | ||
import kotlin.String | ||
import kotlin.jvm.JvmName | ||
|
||
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE) | ||
@JsonDeserialize(builder = SampleType.Builder::class) | ||
public class SampleType( | ||
`return`: () -> String = returnDefault, | ||
) { | ||
private val _return: () -> String = `return` | ||
|
||
@get:JvmName("getReturn") | ||
public val `return`: String | ||
get() = _return.invoke() | ||
|
||
public companion object { | ||
private val returnDefault: () -> String = | ||
{ throw IllegalStateException("Field `return` was not requested") } | ||
|
||
} | ||
|
||
@JsonPOJOBuilder | ||
@JsonIgnoreProperties("__typename") | ||
public class Builder { | ||
private var `return`: () -> String = returnDefault | ||
|
||
@JsonProperty("return") | ||
public fun withReturn(`return`: String): Builder = this.apply { | ||
this.`return` = { `return` } | ||
} | ||
|
||
public fun build(): SampleType = SampleType( | ||
`return` = `return`, | ||
) | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...est/kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithReservedWord/schema.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type SampleType { | ||
return: String! | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters