Exception while deserializing input objects with Set in 4.7.5, bug? #620
-
After shifting version from 4.5.1 to 4.7.5, I faced an exception while serializing input object with Set field: data class UserUpdateInput(
@NotBlank
@Size(min = 1, max = 50)
val id: String,
@field:Size(max = 70)
val firstName: String? = null,
@field:Size(max = 70)
val lastName: String? = null,
@field:Size(max = 10)
val roles: Set<UserRole>? = null,
@field:Valid
val status: UserStatus? = null,
)
enum class UserRole {
User,
Manager,
Admin
} Data fetcher: @DgsData(parentType = "Mutation", field = "userUpdate")
fun userUpdate(
@Valid @InputArgument("input") input: UserUpdateInput,
dfe: DgsDataFetchingEnvironment
): CompletableFuture<UserUpdatePayload> = scope.future {
userService.userUpdate(input)
}
Exception:
Graphql schema input UserUpdateInput {
id: ID!
firstName: String
lastName: String
roles: [UserRole!]
status: UserStatus
}
enum UserRole {
User
Manager
Admin
}
type Mutation {
userUpdate(input: UserUpdateInput!) : UserUpdatePayload
} It's interesting if I exchange Set to List for roles field it starts working. Do you think it's a bug or I did something wrong? I guess it might somehow be related to #607. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Lists are explicitly supported, but Sets are not. The reason being that lists in GraphQL have List semantics, so using a List on the Java/Kotlin side makes most sense. In previous versions this worked in most cases because Jackson was used for part of the input argument conversion (which was conceptually wrong and caused other problems). However, I think we could support Set as well. Could you create an issue for this? |
Beta Was this translation helpful? Give feedback.
Lists are explicitly supported, but Sets are not. The reason being that lists in GraphQL have List semantics, so using a List on the Java/Kotlin side makes most sense. In previous versions this worked in most cases because Jackson was used for part of the input argument conversion (which was conceptually wrong and caused other problems).
However, I think we could support Set as well. Could you create an issue for this?