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

Most upvoted comments

@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…