graphql-kotlin
graphql-kotlin copied to clipboard
Generated code for input with non-standard naming fails
Library Version 5.5.0
Describe the bug Considering the following schema:
input Filter {
AND: [Filter!]
OR: [Filter!]
id: StringFilter
name: StringFilter
}
The maven plugin generates the following class for Jackson:
@Generated
public data class Filter(
public val AND: List<Filter >? = null,
public val OR: List<Filter >? = null,
public val id: StringFilter? = null,
public val name: StringFilter? = null
)
This however will fail to deserialize on the server side, as the request will not send "AND" or "OR" as the name of the field in the JSON.
You need to use @JsonProperty for this situation.
Is there any way to force this?
To Reproduce see above
Expected behavior Serialized json looks correct
Hello 👋
This is indeed an issue with Jackson (kotlinx-serialization does not have this issue) that it does not honor the original field names and instead uses getters to derive the name based on JavaBean conventions. Unsure if this will be addressed within this lib as there are number of issues related to this within jackson-databind - options would be to always annotate the fields with @JsonProperty (which seems like it would redundant for vast majority of cases) OR try to re-implement jackson name logic to determine whether to apply extra annotation (which might be error prone).
I tried switching to kotlinx but now I'm getting a KotlinFrontEndException: Front-end Internal error: Failed to analyze declaration Variables for the generated Query class.