A GraphQL client constructs requests for a GraphQL server and processes the returned data. In a car-rental service, the Reservation service uses one to retrieve the current fleet from the Inventory service instead of relying on a hard-coded list. section 4.5.4 section 4.5
A Quarkus typesafe client is assembled from a small set of application pieces:
- Declare an interface as a client-side view of the GraphQL contract with @GraphQLClientApi and assign it a configuration key. section 4.5.4
- Map a method to the server query with @Query, allowing domain classes such as Car to represent the response. section 4.5.4
Retrieving available cars
Calling the Reservation availability endpoint returns the cars supplied by Inventory, including identifiers, license plates, manufacturers, and models. The client can also be dynamic: construct a query document at runtime, execute it synchronously, and read JSON data or deserialize a list of Car objects.
