Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SmallRye GraphQL 1.3.2 #19927

Merged
merged 1 commit into from
Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<smallrye-health.version>3.1.1</smallrye-health.version>
<smallrye-metrics.version>3.0.1</smallrye-metrics.version>
<smallrye-open-api.version>2.1.10</smallrye-open-api.version>
<smallrye-graphql.version>1.3.1</smallrye-graphql.version>
<smallrye-graphql.version>1.3.2</smallrye-graphql.version>
<smallrye-opentracing.version>2.0.1</smallrye-opentracing.version>
<smallrye-fault-tolerance.version>5.2.1</smallrye-fault-tolerance.version>
<smallrye-jwt.version>3.2.1</smallrye-jwt.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
* On startup, this beans takes Quarkus-specific configuration of GraphQL clients (quarkus.* properties)
* and merges this configuration with the configuration parsed by SmallRye GraphQL itself (CLIENT/mp-graphql/* properties)
*
* The resulting merged configuration resides in the application-scoped `io.smallrye.graphql.client.GraphQLClientConfiguration`
* The resulting merged configuration resides in `io.smallrye.graphql.client.GraphQLClientsConfiguration`
*
* Quarkus configuration overrides SmallRye configuration where applicable.
*/
@Singleton
public class GraphQLClientConfigurationMergerBean {

@Inject
GraphQLClientsConfiguration upstreamConfiguration;

@Inject
Expand All @@ -31,6 +30,7 @@ public class GraphQLClientConfigurationMergerBean {

@PostConstruct
void enhanceGraphQLConfiguration() {
upstreamConfiguration = GraphQLClientsConfiguration.getInstance();
for (Map.Entry<String, GraphQLClientConfig> client : quarkusConfiguration.clients.entrySet()) {
// the raw config key provided in the config, this might be a short class name,
// so translate that into the fully qualified name if applicable
Expand All @@ -43,14 +43,14 @@ void enhanceGraphQLConfiguration() {

GraphQLClientConfig quarkusConfig = client.getValue();
// if SmallRye configuration does not contain this client, simply use it
if (!upstreamConfiguration.getClients().containsKey(configKey)) {
if (upstreamConfiguration.getClient(configKey) == null) {
GraphQLClientConfiguration transformed = new GraphQLClientConfiguration();
transformed.setHeaders(quarkusConfig.headers);
quarkusConfig.url.ifPresent(transformed::setUrl);
upstreamConfiguration.getClients().put(configKey, transformed);
upstreamConfiguration.addClient(configKey, transformed);
} else {
// if SmallRye configuration already contains this client, override it with the Quarkus configuration
GraphQLClientConfiguration upstreamConfig = upstreamConfiguration.getClients().get(configKey);
GraphQLClientConfiguration upstreamConfig = upstreamConfiguration.getClient(configKey);
quarkusConfig.url.ifPresent(upstreamConfig::setUrl);
// merge the headers
if (quarkusConfig.headers != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ public <T> Supplier<T> typesafeClientSupplier(Class<T> targetClassName) {
}

public void setTypesafeApiClasses(List<String> apiClassNames) {
GraphQLClientsConfiguration configBean = Arc.container().instance(GraphQLClientsConfiguration.class).get();
GraphQLClientsConfiguration.setSingleApplication(true);
GraphQLClientsConfiguration configBean = GraphQLClientsConfiguration.getInstance();
List<Class<?>> classes = apiClassNames.stream().map(className -> {
try {
return Class.forName(className, true, Thread.currentThread().getContextClassLoader());
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}).collect(Collectors.toList());
configBean.apiClasses(classes, true);
configBean.addTypesafeClientApis(classes);
}

public RuntimeValue<GraphQLClientSupport> clientSupport(Map<String, String> shortNamesToQualifiedNames) {
Expand Down