OpenLiberty / open-liberty

Open Liberty is a highly composable, fast to start, dynamic application server runtime environment
https://openliberty.io
Eclipse Public License 2.0
1.15k stars 590 forks source link

Upgrade MP GraphQL's SmallRye Implementation #26761

Open Somsss236 opened 11 months ago

Somsss236 commented 11 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?

WhiteCat22 commented 11 months ago

HI @Somsss236,

Please note that the Microprofile GraphQL spec states:

Note that generic types other than subtypes of java.util.Collection (such as java.util.List or java.util.Set) are not allowed to be specified as query return types.

I believe this is the issue that you are running into.

Somsss236 commented 11 months ago

Hi @WhiteCat22 ,

This might relate to the spec but already same behaviour is raised in smallrye graphql and is fixed now. I expect the same to work in openliberty too. Please find the ticket raised in graphql.

https://github.com/smallrye/smallrye-graphql/issues/1928

WhiteCat22 commented 11 months ago

Hi @Somsss236, we do not have an ETA as to when we will update to this version of smallrye-graphql.

I will leave this issue open on our backlog for tracking.

rajsennimalai commented 11 months ago

Hi @WhiteCat22 , Is there any way that I can update this version of smallrye-graphql in open liberty locally in my system? It would be helpful if you could share some reference to apply patch to existing open liberty version and build it locally.