I am exploring graphql and I followed this tutorial https://www.graphql-java.com/tutorials/getting-started-with-spring-boot/ to get a server running. I am now trying to write a Java client for this server using this library: https://github.com/apollographql/apollo-android . My code so far is: https://github.com/alampada/graphql-java-client-tutorial , the readme includes steps to reproduce.
I am not able to have the apollo client library to generate model for my query: https://github.com/alampada/graphql-java-client-tutorial/blob/master/src/main/graphql/com/example/book.graphql, as ./gradlew generateApolloSources
fails with:
Can't query `Book` on type `Query`
----------------------------------------------------
[1]:query BookQuery($id: ID!) {
[2]: Book (id: $id) {
[3]: id
----------------------------------------------------
Could someone explain what I am doing wrong?
Replying for reference as I managed to get this to work.
The graphql file should reference the name of the query from the schema rather than book
.
Working example updated: https://github.com/alampada/graphql-java-client-tutorial/commit/30e7c0955a59dff4675b7f12c26873fe3dd37201#diff-76111f834f0748466f63240b018a755a