-
Notifications
You must be signed in to change notification settings - Fork 317
Cannot use GraphQL argument object whose generic type is declared on @SchemaMapping
method
#349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Between M2 and M3 argument serialization changed from JSON encode/decode to using a We were able to work around it by defining a static sealed class OptionalInput<out T> {
// ...
companion object {
@JvmStatic
fun of(value: String?): OptionalInput<String> {
return Defined(value)
}
}
} Or I think the equivalent java code: class OptionalInput<T> {
// ...
static OptionalInput<String> of(String value) {
return new OptionalInput.Defined(value);
}
} Definitely not perfect, and also doesn't work recursively, but solved the majority of the issues we had with it. |
See also the comments on this PR: #140 |
Indeed as @koenpunt pointed out, we switched from JSON (de)-serialization to using Given that public class FancyEnumFilterInput extends EnumFilterInput<FancyEnum> {
}
@Controller
public class EnumController {
@QueryMapping
public List<FancyEnum> enums(@Argument FancyEnumFilterInput filter) {
return filter.getEnums();
}
} The problem relates more generally to any class-level, generic parameter. We might be able to register a |
@Argument
object with enum generic type fails with type mismatch error
@Argument
object with enum generic type fails with type mismatch error@SchemaMapping
method
We have a project built using
spring-graphql
version1.0.0-M2
that includes filtering logic using input objects with fields of Enum generics. This approach works fine in M2, but when attempting to upgrade to M4 these Enum input fields were now always blank regardless of what was sent in the query. In the latest M6 version, queries including these fields now result in anINTERNAL_ERROR
similar to this:I was able to recreate the issue we're seeing on a clean
spring-boot 2.7.0-M3
project withspring-boot-starter-graphql
and the following:enum.graphqls
EnumController.java
EnumFilterInput.java
FancyEnum.java
The above project on
spring-boot 2.6.6
withspring-graphql 1.0.0-M2
works as expected with the following query:However on
spring-boot 2.7.0-M3
andspring-boot-starter-graphql
(1.0.0-M6
) this query fails with the error given above.Was this an intended change made to the project or is this an issue that can be resolved in a future release? If it is intended, is there a way to get something similar working that is properly supported by
spring-graphql
?Thanks in advance for any help you can provide.
The text was updated successfully, but these errors were encountered: