-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add support for extending type with interface (#715)
* fix: add support for extending type with interface * add test case * remove definitions from implementedInterfaces, expand imports --------- Co-authored-by: Damian Wilkołek <[email protected]>
- Loading branch information
Showing
15 changed files
with
276 additions
and
6 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
...om/netflix/graphql/dgs/codegen/cases/extendedDataClassWithInterface/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.extendedDataClassWithInterface.expected | ||
|
||
public object DgsClient |
25 changes: 25 additions & 0 deletions
25
...netflix/graphql/dgs/codegen/cases/extendedDataClassWithInterface/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,25 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.extendedDataClassWithInterface.expected | ||
|
||
import kotlin.String | ||
|
||
public object DgsConstants { | ||
public object EXAMPLE { | ||
public const val TYPE_NAME: String = "Example" | ||
|
||
public const val Name: String = "name" | ||
|
||
public const val Age: String = "age" | ||
} | ||
|
||
public object A { | ||
public const val TYPE_NAME: String = "A" | ||
|
||
public const val Name: String = "name" | ||
} | ||
|
||
public object B { | ||
public const val TYPE_NAME: String = "B" | ||
|
||
public const val Age: String = "age" | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...x/graphql/dgs/codegen/cases/extendedDataClassWithInterface/expected/client/AProjection.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,19 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.extendedDataClassWithInterface.expected.client | ||
|
||
import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface | ||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
|
||
public class AProjection( | ||
inputValueSerializer: InputValueSerializerInterface? = null, | ||
) : GraphQLProjection(inputValueSerializer) { | ||
public val name: AProjection | ||
get() { | ||
field("name") | ||
return this | ||
} | ||
|
||
public fun onExample(_projection: ExampleProjection.() -> ExampleProjection): AProjection { | ||
fragment("Example", ExampleProjection(), _projection) | ||
return this | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...x/graphql/dgs/codegen/cases/extendedDataClassWithInterface/expected/client/BProjection.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,19 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.extendedDataClassWithInterface.expected.client | ||
|
||
import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface | ||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
|
||
public class BProjection( | ||
inputValueSerializer: InputValueSerializerInterface? = null, | ||
) : GraphQLProjection(inputValueSerializer) { | ||
public val age: BProjection | ||
get() { | ||
field("age") | ||
return this | ||
} | ||
|
||
public fun onExample(_projection: ExampleProjection.() -> ExampleProjection): BProjection { | ||
fragment("Example", ExampleProjection(), _projection) | ||
return this | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...hql/dgs/codegen/cases/extendedDataClassWithInterface/expected/client/ExampleProjection.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,20 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.extendedDataClassWithInterface.expected.client | ||
|
||
import com.netflix.graphql.dgs.client.codegen.InputValueSerializerInterface | ||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
|
||
public class ExampleProjection( | ||
inputValueSerializer: InputValueSerializerInterface? = null, | ||
) : GraphQLProjection(inputValueSerializer) { | ||
public val name: ExampleProjection | ||
get() { | ||
field("name") | ||
return this | ||
} | ||
|
||
public val age: ExampleProjection | ||
get() { | ||
field("age") | ||
return this | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
.../com/netflix/graphql/dgs/codegen/cases/extendedDataClassWithInterface/expected/types/A.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.extendedDataClassWithInterface.expected.types | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonSubTypes | ||
import com.fasterxml.jackson.`annotation`.JsonTypeInfo | ||
import kotlin.String | ||
import kotlin.Suppress | ||
import kotlin.jvm.JvmName | ||
|
||
@JsonTypeInfo( | ||
use = JsonTypeInfo.Id.NAME, | ||
include = JsonTypeInfo.As.PROPERTY, | ||
property = "__typename", | ||
) | ||
@JsonSubTypes(value = [ | ||
JsonSubTypes.Type(value = Example::class, name = "Example") | ||
]) | ||
public sealed interface A { | ||
@Suppress("INAPPLICABLE_JVM_NAME") | ||
@get:JvmName("getName") | ||
public val name: String? | ||
} |
21 changes: 21 additions & 0 deletions
21
.../com/netflix/graphql/dgs/codegen/cases/extendedDataClassWithInterface/expected/types/B.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.extendedDataClassWithInterface.expected.types | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonSubTypes | ||
import com.fasterxml.jackson.`annotation`.JsonTypeInfo | ||
import kotlin.Int | ||
import kotlin.Suppress | ||
import kotlin.jvm.JvmName | ||
|
||
@JsonTypeInfo( | ||
use = JsonTypeInfo.Id.NAME, | ||
include = JsonTypeInfo.As.PROPERTY, | ||
property = "__typename", | ||
) | ||
@JsonSubTypes(value = [ | ||
JsonSubTypes.Type(value = Example::class, name = "Example") | ||
]) | ||
public sealed interface B { | ||
@Suppress("INAPPLICABLE_JVM_NAME") | ||
@get:JvmName("getAge") | ||
public val age: Int? | ||
} |
65 changes: 65 additions & 0 deletions
65
...etflix/graphql/dgs/codegen/cases/extendedDataClassWithInterface/expected/types/Example.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,65 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.extendedDataClassWithInterface.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.Int | ||
import kotlin.String | ||
import kotlin.Suppress | ||
import kotlin.jvm.JvmName | ||
|
||
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE) | ||
@JsonDeserialize(builder = Example.Builder::class) | ||
public class Example( | ||
name: () -> String? = nameDefault, | ||
age: () -> Int? = ageDefault, | ||
) : A, | ||
B { | ||
private val __name: () -> String? = name | ||
|
||
private val __age: () -> Int? = age | ||
|
||
@Suppress("INAPPLICABLE_JVM_NAME") | ||
@get:JvmName("getName") | ||
override val name: String? | ||
get() = __name.invoke() | ||
|
||
@Suppress("INAPPLICABLE_JVM_NAME") | ||
@get:JvmName("getAge") | ||
override val age: Int? | ||
get() = __age.invoke() | ||
|
||
public companion object { | ||
private val nameDefault: () -> String? = | ||
{ throw IllegalStateException("Field `name` was not requested") } | ||
|
||
private val ageDefault: () -> Int? = | ||
{ throw IllegalStateException("Field `age` was not requested") } | ||
} | ||
|
||
@JsonPOJOBuilder | ||
@JsonIgnoreProperties("__typename") | ||
public class Builder { | ||
private var name: () -> String? = nameDefault | ||
|
||
private var age: () -> Int? = ageDefault | ||
|
||
@JsonProperty("name") | ||
public fun withName(name: String?): Builder = this.apply { | ||
this.name = { name } | ||
} | ||
|
||
@JsonProperty("age") | ||
public fun withAge(age: Int?): Builder = this.apply { | ||
this.age = { age } | ||
} | ||
|
||
public fun build(): Example = Example( | ||
name = name, | ||
age = age, | ||
) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...otlin/com/netflix/graphql/dgs/codegen/cases/extendedDataClassWithInterface/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,11 @@ | ||
interface A { name : String } | ||
|
||
type Example implements A { | ||
name: String | ||
} | ||
|
||
interface B { age :Int } | ||
|
||
extend type Example implements B{ | ||
age :Int | ||
} |
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
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