-
Notifications
You must be signed in to change notification settings - Fork 173
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
Building schema parser fails when java.util.List is used with a type parameter from a generic class #460
Comments
The same issue happens when the type that it tries to figure out is actually generic over multiple levels: type Query {
item: Item!
}
type Item {
id: ID!
} And backing Java classes like: class AbstractItem<T> {
T id;
}
class BaseItem<T> extends AbstractItem<T> {}
class ConcreteItem extends BaseItem<Long> {} leads to the same exception
|
Hello guys, |
It seems like this issue also happens when a generic has a non-generic, non-concrete (interface or abstract class) type as well. For example, interface A { val name: String }
class B: A {
override val name: String = "B"
}
class C: A {
override val name: String = "C"
}
class Resolver: GraphQLQueryResolver {
fun listAInstances(): Page<A> = ...
} Schema type Query {
listAInstances: APage
}
type APage {
contents: [A]
}
type A {
name: String
} Is there any way to work around this without completely duplicating the graphql |
Affected version: 6.2.0
Description
I am having difficulties backing an input object with a Java class that inherits a
java.util.List<T>
property from its generic super class.Given this schema:
And given this generic base class:
And given this backing class for the
MutationInput
input object:Then building the
SchemaParser
object fails with this exception:It seems the parameters passed to
TypeUtils.getRawType(Type, Type)
do not carry sufficient information for determining the raw type. The required information would to be contained inthis.mostSpecificType
.A few things I have already tried:
Item
is a nested class or not. The issue occurs in either case.String
is used for type parameterT
instead ofMutationInput.Item
.MutationInput
has an own propertyjava.util.List<MutationInput.Item>
and has no generic super class:MutationInput
overrides getter and setter foritems
(getters and setters not shown above for brevity).Steps to reproduce the bug
I have created a minimal Spring Boot application for reproducing this issue.
Given you have OpenJDK 15 installed.
./mvnw clean spring-boot:run "-Dspring-boot.run.profiles=generics"
.Expected behavior: Starting the Spring Boot application succeeds.
Actual behavior: Starting the Spring Boot application fails with this root cause:
Starting the application with an alternative profile that replaces the backing class with a “non-generic” one succeeds:
./mvnw clean spring-boot:run "-Dspring-boot.run.profiles=nogenerics"
.The text was updated successfully, but these errors were encountered: