Skip to content

Commit

Permalink
Merge pull request #45516 from mcruzdev/config-vertx-graphql
Browse files Browse the repository at this point in the history
Convert vertx-graphql to use @ConfigMapping
  • Loading branch information
gsmet authored Jan 11, 2025
2 parents 215eb29 + 1b8811e commit 4b0ff98
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
3 changes: 0 additions & 3 deletions extensions/vertx-graphql/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-AlegacyConfigRoot=true</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
package io.quarkus.vertx.graphql.deployment;

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;

@ConfigRoot
public final class VertxGraphqlConfig {
@ConfigMapping(prefix = "quarkus.vertx-graphql")
public interface VertxGraphqlConfig {

/**
* GraphQL UI configuration
*/
@ConfigItem
VertxGraphqlUiConfig ui;
VertxGraphqlUiConfig ui();

@ConfigGroup
public static class VertxGraphqlUiConfig {
interface VertxGraphqlUiConfig {
/**
* If GraphQL UI should be included every time. By default, this is only included when the application is running
* in dev mode.
*/
@ConfigItem
boolean alwaysInclude;
@WithDefault("false")
boolean alwaysInclude();

/**
* The path where GraphQL UI is available.
* <p>
* The value `/` is not allowed as it blocks the application from serving anything else.
*/
@ConfigItem(defaultValue = "graphql-ui")
String path;
@WithDefault("graphql-ui")
String path();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ void registerVertxGraphqlUI(VertxGraphqlRecorder recorder, VertxGraphqlConfig co
return;
}

Matcher matcher = TRAILING_SLASH_SUFFIX_REGEX.matcher(config.ui.path);
Matcher matcher = TRAILING_SLASH_SUFFIX_REGEX.matcher(config.ui().path());
String path = matcher.replaceAll("");
if (path.isEmpty()) {
throw new ConfigurationException(
"quarkus.vertx-graphql.ui.path was set to \"" + config.ui.path
"quarkus.vertx-graphql.ui.path was set to \"" + config.ui().path()
+ "\", this is not allowed as it blocks the application from serving anything else.");
}

Expand All @@ -101,7 +101,7 @@ void registerVertxGraphqlUI(VertxGraphqlRecorder recorder, VertxGraphqlConfig co
}

private static boolean doNotIncludeVertxGraphqlUi(LaunchModeBuildItem launchMode, VertxGraphqlConfig config) {
return !launchMode.getLaunchMode().isDevOrTest() && !config.ui.alwaysInclude;
return !launchMode.getLaunchMode().isDevOrTest() && !config.ui().alwaysInclude();
}

@BuildStep
Expand Down
3 changes: 0 additions & 3 deletions extensions/vertx-graphql/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-AlegacyConfigRoot=true</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
Expand Down

0 comments on commit 4b0ff98

Please sign in to comment.