smallrye-graphql: Are Generics not supported?
I’m having:
public interface PageType<T> {
List<T> getItems();
boolean isHasNextPage();
boolean isHasPreviousPage();
long getTotalCount();
}
@Type("ContinentPage")
public class ContinentPageType implements PageType<ContinentType> {
private final List<ContinentType> items;
private final boolean hasNextPage;
private final boolean hasPreviousPage;
private final long totalCount;
// ctor, getters, setters omitted to keep issue text shorter
}
@GraphQLApi
public class MyGraphQLApi {
@Query("continents")
@Description("Get a page of continents")
public ContinentPageType getContinentPage() {
return new ContinentPageType(..);
}
}
But this gives:
Caused by: io.smallrye.graphql.schema.SchemaBuilderException: Don't know what to do with [T] of kind [TYPE_VARIABLE]
at io.smallrye.graphql.schema.creator.ReferenceCreator.getReference(ReferenceCreator.java:214)
at io.smallrye.graphql.schema.creator.ReferenceCreator.getReference(ReferenceCreator.java:202)
at io.smallrye.graphql.schema.creator.ReferenceCreator.createReferenceForInterfaceField(ReferenceCreator.java:118)
at io.smallrye.graphql.schema.creator.FieldCreator.createFieldForInterface(FieldCreator.java:55)
at io.smallrye.graphql.schema.creator.type.InterfaceCreator.addFields(InterfaceCreator.java:78)
at io.smallrye.graphql.schema.creator.type.InterfaceCreator.create(InterfaceCreator.java:57)
at io.smallrye.graphql.schema.creator.type.InterfaceCreator.create(InterfaceCreator.java:31)
at io.smallrye.graphql.schema.SchemaBuilder.createAndAddToSchema(SchemaBuilder.java:148)
at io.smallrye.graphql.schema.SchemaBuilder.addTypesToSchema(SchemaBuilder.java:107)
at io.smallrye.graphql.schema.SchemaBuilder.generateSchema(SchemaBuilder.java:88)
at io.smallrye.graphql.schema.SchemaBuilder.build(SchemaBuilder.java:60)
Note that in the @GraphQLApi I don’t directly refer to the PageType<T> interface.
It would be nice to have some sort of Page contract in my Java classes.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 33 (17 by maintainers)
Commits related to this issue
- #281 - generics support in schema generation for query outputs (inclusing interfaces) — committed to velias/smallrye-graphql by velias 4 years ago
- #281 - added test for mutation and some assertions for generated schema — committed to velias/smallrye-graphql by velias 4 years ago
- #281 patched logging, source code formatted — committed to velias/smallrye-graphql by velias 4 years ago
- #281 - generics support in schema generation for query outputs (inclusing interfaces) — committed to velias/smallrye-graphql by velias 4 years ago
- #281 - added test for mutation and some assertions for generated schema — committed to velias/smallrye-graphql by velias 4 years ago
- #281 patched logging, source code formatted — committed to velias/smallrye-graphql by velias 4 years ago
- #281 - rebased to latest master — committed to velias/smallrye-graphql by velias 4 years ago
- Merge pull request #385 from velias/281-generics #281 - support for generics — committed to smallrye/smallrye-graphql by phillip-kruger 4 years ago
- Added test for interface problem reported in #281 comments and patched in previous commit — committed to velias/smallrye-graphql by velias 4 years ago
- Merge pull request #512 from velias/master Added test for interface problem reported in #281 comments and patched — committed to smallrye/smallrye-graphql by phillip-kruger 4 years ago
@apellizzn OK, I was able to create testing project and reproduce this error. So please create new issue and I’ll try to patch it. Would be good to have patch in smallrye-graphql 1.0.15 and next Quarkus
Yea I don’t think it’s difficult. Just need to do it, and make sure that we boil it up to the spec.
OK, so it is expected behavior. I will have a look in the weekend to see how the internals are working…