Java generated response class in Android doesn't implement 'Operation.Data'

Total graphql noob here. I have an Android Java app that works. I want to make a query to a graphql server (podchaser.com). I was following the Client (Kotlin) v3 docs (though I don’t know or use Kotlin). In the Write your first query section, when I built the project, Apollo generated Java classes.

I created a Java class to create an ApolloClient and a method to execute my query. The execute query method failed on build:

    public static Single<ApolloResponse> executePodcastSearchQuery( String searchTerm ) {

The error is:

Type parameter 'com.alcyonltd.droid.osmium.podchaser.PodcastSearchQuery.Data' is not within its bound; should implement 'com.apollographql.apollo3.api.Operation.Data'

If I edit the PodcastSearchQuery.Data class to add Operation.Data as instructed (I know that the generated files are not to be edited), my execute method then shows no errors.

So, I can never run the app because the PodcastSearchQuery.Data class is regenerated every time without implementing Operation.Data causing the build to fail.

Is there a way around this?

Hi :wave: You might be hitting https://youtrack.jetbrains.com/issue/KTIJ-22127.

In general, from Java, I’d recommend you stay with version 2.x for the time being as the API is easier to work with from Java. You can follow this issue for improvements to the Java interop in version 3.x

Thank you for the response and for the new issue you created!