Skip to content

Commit

Permalink
Merge pull request #19927 from jmartisk/srgql-1.3.2
Browse files Browse the repository at this point in the history
SmallRye GraphQL 1.3.2
  • Loading branch information
gsmet authored Sep 6, 2021
2 parents 3d5abb4 + 40ced5e commit 7627246
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
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

0 comments on commit 7627246

Please sign in to comment.