smallrye-graphql icon indicating copy to clipboard operation
smallrye-graphql copied to clipboard

Problems with Generics in quarkus 3

Open robp94 opened this issue 2 years ago • 3 comments

Currently migrating to quarkus 3. I am getting some errors, the same code works with quarkus 2.

public record InsertLangEntryGQLJ<T>(String lang, T record) {
    @JsonbCreator
    public InsertLangEntryGQLJ {
    }
}

public record InsertTechnicalLocationInputJ(@Id String id,
                                            List<@NonNull InsertLangEntryGQLJ<@NonNull InsertTechnicalLocationRecordGQLJ>> multiLangRecords) {

    @JsonbCreator
    public InsertTechnicalLocationInputJ {
    }
}

Yasson fails here in org.eclipse.yasson.internal.ReflectionUtils#getRawType image

In the reproducer there is a Kotlin and a Java version, both fail for quarkus 3 and work for quarkus 2. When switching between quarkus version, you need to change javax vs jakarta, and you should change the koltin version (both used version are in the pom as comment).

Mutation to trigger the error.

mutation testJava{
  testJava(input:{
    id: 0,
    multiLangRecords: {
      lang: "",
      record: {
        description: ""
      }
    },  
  })}

code-with-quarkus3-graphql-generics.zip

robp94 avatar May 02 '23 10:05 robp94

We think that this is the reason of the bug: https://github.com/eclipse-ee4j/yasson/issues/599

mskacelik avatar May 05 '23 10:05 mskacelik

Ok, unfortunate, so this will probably take some time until it gets fixed.

robp94 avatar May 05 '23 10:05 robp94

I think I found a workaround for the moment. T needs to implement an interface or extends an abstract class. A dummy is fine, it is not added to the schema.

For java this means that T can not be a record, in kotlin a data class is possible.

robp94 avatar May 16 '23 12:05 robp94