-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #700 from Netflix/feature/escape-projection-args
Escape projection argument names in kotlin2
- Loading branch information
Showing
11 changed files
with
204 additions
and
17 deletions.
There are no files selected for viewing
13 changes: 12 additions & 1 deletion
13
...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 |
---|---|---|
@@ -1,3 +1,14 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithReservedWord.expected | ||
|
||
public object DgsClient | ||
import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface | ||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
import com.netflix.graphql.dgs.codegen.cases.dataClassWithReservedWord.expected.client.QueryProjection | ||
import graphql.language.OperationDefinition | ||
import kotlin.String | ||
|
||
public object DgsClient { | ||
public fun buildQuery(inputValueSerializer: InputValueSerializerInterface? = null, | ||
_projection: QueryProjection.() -> QueryProjection): String = | ||
GraphQLProjection.asQuery(OperationDefinition.Operation.QUERY, | ||
QueryProjection(inputValueSerializer), _projection) | ||
} |
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
21 changes: 21 additions & 0 deletions
21
...x/graphql/dgs/codegen/cases/dataClassWithReservedWord/expected/client/PersonProjection.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,21 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithReservedWord.expected.client | ||
|
||
import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface | ||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
import kotlin.String | ||
|
||
public class PersonProjection( | ||
inputValueSerializer: InputValueSerializerInterface? = null, | ||
) : GraphQLProjection(inputValueSerializer) { | ||
public val `interface`: PersonProjection | ||
get() { | ||
field("interface") | ||
return this | ||
} | ||
|
||
public fun info(`package`: String? = default<PersonProjection, String?>("package")): | ||
PersonProjection { | ||
field("info", "package" to `package`) | ||
return this | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...ix/graphql/dgs/codegen/cases/dataClassWithReservedWord/expected/client/QueryProjection.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,15 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithReservedWord.expected.client | ||
|
||
import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface | ||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
import kotlin.String | ||
|
||
public class QueryProjection( | ||
inputValueSerializer: InputValueSerializerInterface? = null, | ||
) : GraphQLProjection(inputValueSerializer) { | ||
public fun people(_alias: String? = null, _projection: PersonProjection.() -> PersonProjection): | ||
QueryProjection { | ||
field(_alias, "people", PersonProjection(inputValueSerializer), _projection) | ||
return this | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
.../com/netflix/graphql/dgs/codegen/cases/dataClassWithReservedWord/expected/types/Person.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,62 @@ | ||
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 = Person.Builder::class) | ||
public class Person( | ||
info: () -> String? = infoDefault, | ||
`interface`: () -> String? = interfaceDefault, | ||
) { | ||
private val __info: () -> String? = info | ||
|
||
private val __interface: () -> String? = `interface` | ||
|
||
@get:JvmName("getInfo") | ||
public val info: String? | ||
get() = __info.invoke() | ||
|
||
@get:JvmName("getInterface") | ||
public val `interface`: String? | ||
get() = __interface.invoke() | ||
|
||
public companion object { | ||
private val infoDefault: () -> String? = | ||
{ throw IllegalStateException("Field `info` was not requested") } | ||
|
||
|
||
private val interfaceDefault: () -> String? = | ||
{ throw IllegalStateException("Field `interface` was not requested") } | ||
|
||
} | ||
|
||
@JsonPOJOBuilder | ||
@JsonIgnoreProperties("__typename") | ||
public class Builder { | ||
private var info: () -> String? = infoDefault | ||
|
||
private var `interface`: () -> String? = interfaceDefault | ||
|
||
@JsonProperty("info") | ||
public fun withInfo(info: String?): Builder = this.apply { | ||
this.info = { info } | ||
} | ||
|
||
@JsonProperty("interface") | ||
public fun withInterface(`interface`: String?): Builder = this.apply { | ||
this.`interface` = { `interface` } | ||
} | ||
|
||
public fun build(): Person = Person( | ||
info = info, | ||
`interface` = `interface`, | ||
) | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...n/com/netflix/graphql/dgs/codegen/cases/dataClassWithReservedWord/expected/types/Query.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.collections.List | ||
import kotlin.jvm.JvmName | ||
|
||
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE) | ||
@JsonDeserialize(builder = Query.Builder::class) | ||
public class Query( | ||
people: () -> List<Person?>? = peopleDefault, | ||
) { | ||
private val __people: () -> List<Person?>? = people | ||
|
||
@get:JvmName("getPeople") | ||
public val people: List<Person?>? | ||
get() = __people.invoke() | ||
|
||
public companion object { | ||
private val peopleDefault: () -> List<Person?>? = | ||
{ throw IllegalStateException("Field `people` was not requested") } | ||
|
||
} | ||
|
||
@JsonPOJOBuilder | ||
@JsonIgnoreProperties("__typename") | ||
public class Builder { | ||
private var people: () -> List<Person?>? = peopleDefault | ||
|
||
@JsonProperty("people") | ||
public fun withPeople(people: List<Person?>?): Builder = this.apply { | ||
this.people = { people } | ||
} | ||
|
||
public fun build(): Query = Query( | ||
people = people, | ||
) | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...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 |
---|---|---|
@@ -1,3 +1,12 @@ | ||
type SampleType { | ||
return: String! | ||
} | ||
|
||
type Query { | ||
people: [Person] | ||
} | ||
|
||
type Person { | ||
info(package: String): String | ||
interface: 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
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
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