Kobby is a codegen plugin of Kotlin DSL Client by GraphQL schema. The generated DSL supports execution of complex GraphQL queries, mutation and subscriptions in Kotlin with syntax similar to native GraphQL syntax.
Apache License 2.0
83
stars
4
forks
source link
Validation error when deserializing nested GraphQL inputs #13
The ShapeInput contains nested PointInput. For such an inputs Kobby generates DTO classes:
public enum class ShapeType {
POINT,
LINE,
POLYGON,
}
@JsonTypeName(value = "PointInput")
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "__typename",
defaultImpl = PointInput::class
)
@JsonInclude(value = JsonInclude.Include.NON_ABSENT)
public data class PointInput(
public val x: Double,
public val y: Double
)
@JsonTypeName(value = "ShapeInput")
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "__typename",
defaultImpl = ShapeInput::class
)
@JsonInclude(value = JsonInclude.Include.NON_ABSENT)
public data class ShapeInput(
public val type: ShapeType,
public val points: List<PointInput>,
public val holes: List<List<PointInput>>? = null
)
When I try to send the ShapeInput with nested PointInput to GraphQL server I receive an validation error:
The variables input contains a field name '__typename' that is not defined for input object type 'PointInput'
To avoid such validation errors Kobby must not generate the JsonTypeName and the JsonTypeInfo annotations for input GraphQL types. For other GraphQL types, the behavior should remain the same.
Let define nested GraphQL inputs:
The
ShapeInput
contains nestedPointInput
. For such an inputs Kobby generates DTO classes:When I try to send the
ShapeInput
with nestedPointInput
to GraphQL server I receive an validation error:To avoid such validation errors Kobby must not generate the
JsonTypeName
and theJsonTypeInfo
annotations for input GraphQL types. For other GraphQL types, the behavior should remain the same.