eclipse / microprofile-graphql

microprofile-graphql
Apache License 2.0
98 stars 40 forks source link

GraphQL schema is not generated when response type has Generics (Nested field) #550

Closed Somsss236 closed 8 months ago

Somsss236 commented 8 months ago

Hi, I'm using the following code to generate GraphQL query. The nested field in response type has Generic type (Java Generics). Due to this schema is not generated automatically and getting exception graphql.AssertException: type Object not found in schema during startup.

I'm Using (Open Liberty 23.0.0.10)

Here is my Example Code:

public interface GenericType<T> {
    T getValue();
}

public class ResponseName implements GenericType<String> {

    String value;

    public ResponseName(String value) {
        this.value = value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Override
    public String getValue() {
        // TODO Auto-generated method stub
        throw new UnsupportedOperationException("Unimplemented method 'getValue'");
    }

}

public class Response  {

    ResponseName value;

    public String getValue() {
        throw new UnsupportedOperationException("Unimplemented method 'getName'");
    }

    public void setValue(ResponseName value) {
        this.value = value;
    }

}
    @Query
    public Response getAllLocationsTest(@Name("location") String location) throws UnknownLocationException {
        Response rs = new Response();
        rs.setValue(new ResponseName(location));
        return rs;
    }

Exception:

image

Could you assist to me resolve the issue?

jmartisk commented 8 months ago

This looks very much the same as the issue that was fixed by https://github.com/smallrye/smallrye-graphql/pull/1931 - the fix should be in SmallRye GraphQL 2.5.0+. I assume you're on an older version?