liveBook · Manning

GraphQL client

As explained in Quarkus in Action

A GraphQL client is software that constructs and sends GraphQL requests to a GraphQL server and processes its responses.

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.

How Quarkus in Action covers it

How deep it goes
Implements extension setup, typed interfaces, query mapping, endpoint configuration, injection, and dynamic query execution.
Examples
Demonstrates a typed cars query, endpoint configuration, client injection, returned car JSON, and dynamic query construction.
What it assumes
Assumes a GraphQL server contract and domain classes, while establishing the distinction between GraphQL client and server roles.
What you can do after
Apply it via the SmallRye GraphQL client to query a remote Inventory service with typed or dynamically constructed requests.
How it connects
Connects GraphQL clients with GraphQL servers, GraphQL APIs, domain classes, dependency injection, and service-to-service communication.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quarkus in Action. The section links point to the parts of the book it draws on.