Allow using a sub-interface of a generic interface as API with Typesafe client#2151
Allow using a sub-interface of a generic interface as API with Typesafe client#2151lbuffler wants to merge 2 commits intosmallrye:mainfrom
Conversation
|
Hi @lbuffler, thank you for the PR! Also, if I am not mistaken, you would probably need to add your sub-interface implementation to the client model implementation (which has been used by Quarkus since 3.9.0). which, instead of Java reflection for query building, uses a Jandex API. Somewhere here: I can take care of this part, if you want... |
|
Hi @mskacelik, thanks for your feedback. Sure, I'll add some tests, I wanted to do it but wasn't sure where they should go. About Quarkus, I noticed that it was failing in a different way but haven't dug more about this. Now that you say it, it's obvious it would use the Jandex index instead of reflection. I never had the opportunity to look at Jandex, so this would be a good occasion to start, I'll look at it and let you know if I need help. |
6aa0d6e to
e6ffcf0
Compare
Goal
I want to be able to write a GraphQL api and provide a Java interface for my clients, whilst keeping GraphQL strength of allowing clients to choose exactly what data they will receive. For that, we could use generics.
So, as the writer of the GraphQL endpoint, I would for example give this to my clients:
Tcould be for example:public record MyItemSimple(String name) {}orpublic record MyItemFull(String name, String extraLongDescription) {}Then, on the client side, I would be able to choose between:
or
depending on the data needed, and
getItem()would return exactly that.Problem
That fails with:
The only way to get it working is to explicitly override the generic method.
Solution
This PR provides a way to fix this and makes the scenario described here as expected.