liveBook · Manning

Configuration key

As explained in Quarkus in Action

A configuration key is the named identifier associated with a configuration value.

A configuration key names a client so its settings can be supplied outside the client interface. In a Quarkus service, this replaces a hardcoded endpoint URL with a property in application.properties. The annotation names the client; the property uses that name to identify which client receives the URL. section 11.1.1 section 4.5.4

Move a REST client URL into configuration

Change @RegisterRestClient(baseUri = "http://localhost:8081") to @RegisterRestClient(configKey = "reservations"). Then set quarkus.rest-client.reservations.url=http://localhost:8081 in application.properties. The URL remains local for now, but it is no longer fixed in the interface. section 11.1.1

Name a GraphQL client

Annotate the typesafe client interface with @GraphQLClientApi(configKey = "inventory") and set quarkus.smallrye-graphql-client.inventory.url=http://localhost:8083/graphql. The name can also identify the client at injection with @GraphQLClient("inventory"). Distinct names allow multiple GraphQL client APIs to have different settings. section 4.5.4

For a REST client, a custom name is optional: the interface’s fully qualified name can serve as the default configuration key. A custom name avoids tying the property to a class name or package that may change. Moving a URL into application.properties does not itself make a localhost address usable in the cloud; that endpoint still needs to be changed for deployment. section 11.1.1

How Quarkus in Action covers it

How deep it goes
Works through annotation–property pairs and a REST client default; stops short of replacing local URLs with cloud endpoints.
Examples
Uses reservation and rental REST client URLs plus an inventory GraphQL client URL and injection name.
What it assumes
Assumes Java interface and application.properties familiarity while explaining how an annotation name maps to a client property.
What you can do after
Apply it via Quarkus REST Client or SmallRye GraphQL Client to associate named clients with configurable endpoint URLs.
How it connects
Connects REST clients and GraphQL clients to application.properties, dependency injection, and externalized configuration.

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.