diff --git a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java b/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java index 41e3249dd6bee..be21c4d25f097 100644 --- a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java +++ b/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java @@ -51,6 +51,8 @@ import io.quarkus.maven.dependency.ResolvedDependency; import io.quarkus.runtime.LaunchMode; import io.quarkus.runtime.RuntimeValue; +import io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLConfig; +import io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLConfigMapping; import io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLRecorder; import io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLRuntimeConfig; import io.quarkus.vertx.http.deployment.BodyHandlerBuildItem; diff --git a/extensions/smallrye-graphql/deployment/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor b/extensions/smallrye-graphql/deployment/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor deleted file mode 100644 index d0436a2893b7f..0000000000000 --- a/extensions/smallrye-graphql/deployment/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor +++ /dev/null @@ -1 +0,0 @@ -io.quarkus.smallrye.graphql.deployment.SmallRyeGraphQLConfigMapping diff --git a/extensions/smallrye-graphql/deployment/src/test/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLConfigMappingTest.java b/extensions/smallrye-graphql/deployment/src/test/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLConfigMappingTest.java new file mode 100644 index 0000000000000..dbdbfb9f71bdb --- /dev/null +++ b/extensions/smallrye-graphql/deployment/src/test/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLConfigMappingTest.java @@ -0,0 +1,31 @@ +package io.quarkus.smallrye.graphql.deployment; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +import io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLConfigMapping; +import io.smallrye.config.SmallRyeConfig; +import io.smallrye.config.SmallRyeConfigBuilder; + +class SmallRyeGraphQLConfigMappingTest { + @Test + void graphQlRelocates() { + SmallRyeConfig config = new SmallRyeConfigBuilder() + .withDefaultValue("quarkus.smallrye-graphql.show-runtime-exception-message", "org.acme.CustomRuntimeException") + .withInterceptors(new SmallRyeGraphQLConfigMapping()) + .build(); + + assertEquals("org.acme.CustomRuntimeException", config.getRawValue("mp.graphql.showErrorMessage")); + } + + @Test + void graphQlRelocatesDiscovered() { + SmallRyeConfig config = new SmallRyeConfigBuilder() + .withDefaultValue("quarkus.smallrye-graphql.show-runtime-exception-message", "org.acme.CustomRuntimeException") + .addDiscoveredInterceptors() + .build(); + + assertEquals("org.acme.CustomRuntimeException", config.getRawValue("mp.graphql.showErrorMessage")); + } +} diff --git a/extensions/smallrye-graphql/runtime/pom.xml b/extensions/smallrye-graphql/runtime/pom.xml index 9866a9142f5d9..b15446b6d2a70 100644 --- a/extensions/smallrye-graphql/runtime/pom.xml +++ b/extensions/smallrye-graphql/runtime/pom.xml @@ -31,6 +31,10 @@ io.quarkus quarkus-jsonb + + io.smallrye + smallrye-graphql-schema-builder + io.smallrye smallrye-graphql-cdi diff --git a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLConfig.java b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLConfig.java similarity index 74% rename from extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLConfig.java rename to extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLConfig.java index c9512c1ef40b4..279262d62d534 100644 --- a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLConfig.java +++ b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLConfig.java @@ -1,15 +1,16 @@ -package io.quarkus.smallrye.graphql.deployment; +package io.quarkus.smallrye.graphql.runtime; import java.util.List; import java.util.Optional; import io.quarkus.runtime.annotations.ConfigDocSection; import io.quarkus.runtime.annotations.ConfigItem; +import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.graphql.schema.helper.TypeAutoNameStrategy; import io.smallrye.graphql.spi.config.LogPayloadOption; -@ConfigRoot(name = "smallrye-graphql") +@ConfigRoot(name = "smallrye-graphql", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) public class SmallRyeGraphQLConfig { /** @@ -17,49 +18,49 @@ public class SmallRyeGraphQLConfig { * By default, this value will be resolved as a path relative to `${quarkus.http.root-path}`. */ @ConfigItem(defaultValue = "graphql") - String rootPath; + public String rootPath; /** * Enable metrics. By default this is false. If set to true, a metrics extension is required. */ @ConfigItem(name = "metrics.enabled") - Optional metricsEnabled; + public Optional metricsEnabled; /** * Enable tracing. By default this will be enabled if the tracing extension is added. */ @ConfigItem(name = "tracing.enabled") - Optional tracingEnabled; + public Optional tracingEnabled; /** * Enable validation. By default this will be enabled if the Hibernate Validator extension is added. */ @ConfigItem(name = "validation.enabled") - Optional validationEnabled; + public Optional validationEnabled; /** * Enable eventing. Allow you to receive events on bootstrap and execution. */ @ConfigItem(name = "events.enabled", defaultValue = "false") - boolean eventsEnabled; + public boolean eventsEnabled; /** * Enable GET Requests. Allow queries via HTTP GET. */ @ConfigItem(name = "http.get.enabled") - Optional httpGetEnabled; + public Optional httpGetEnabled; /** * Enable Query parameter on POST Requests. Allow POST request to override or supply values in a query parameter. */ @ConfigItem(name = "http.post.queryparameters.enabled") - Optional httpPostQueryParametersEnabled; + public Optional httpPostQueryParametersEnabled; /** * Change the type naming strategy. */ @ConfigItem(defaultValue = "Default") - TypeAutoNameStrategy autoNameStrategy; + public TypeAutoNameStrategy autoNameStrategy; /** * List of extension fields that should be included in the error response. @@ -67,88 +68,87 @@ public class SmallRyeGraphQLConfig { * [exception,classification,code,description,validationErrorType,queryPath] */ @ConfigItem - Optional> errorExtensionFields; + public Optional> errorExtensionFields; /** * List of Runtime Exceptions class names that should show the error message. * By default Runtime Exception messages will be hidden and a generic `Server Error` message will be returned. */ @ConfigItem - Optional> showRuntimeExceptionMessage; + public Optional> showRuntimeExceptionMessage; /** * List of Checked Exceptions class names that should hide the error message. * By default Checked Exception messages will show the exception message. */ @ConfigItem - Optional> hideCheckedExceptionMessage; + public Optional> hideCheckedExceptionMessage; /** * The default error message that will be used for hidden exception messages. * Defaults to "Server Error" */ @ConfigItem - Optional defaultErrorMessage; + public Optional defaultErrorMessage; /** * Print the data fetcher exception to the log file. Default `true` in dev and test mode, default `false` in prod. */ @ConfigItem - Optional printDataFetcherException; + public Optional printDataFetcherException; /** * Make the schema available over HTTP. */ @ConfigItem(defaultValue = "true") - boolean schemaAvailable; + public boolean schemaAvailable; /** * Include the Scalar definitions in the schema. */ @ConfigItem(defaultValue = "false") - boolean schemaIncludeScalars; + public boolean schemaIncludeScalars; /** * Include the schema internal definition in the schema. */ @ConfigItem(defaultValue = "false") - boolean schemaIncludeSchemaDefinition; + public boolean schemaIncludeSchemaDefinition; /** * Include Directives in the schema. */ @ConfigItem(defaultValue = "false") - boolean schemaIncludeDirectives; + public boolean schemaIncludeDirectives; /** * Include Introspection Types in the schema. */ @ConfigItem(defaultValue = "false") - boolean schemaIncludeIntrospectionTypes; + public boolean schemaIncludeIntrospectionTypes; /** * Log the payload (and optionally variables) to System out. */ @ConfigItem(defaultValue = "off") - LogPayloadOption logPayload; + public LogPayloadOption logPayload; /** * Set the Field visibility. */ @ConfigItem(defaultValue = "default") - String fieldVisibility; + public String fieldVisibility; /** * Exceptions that should be unwrapped (class names). */ @ConfigItem - Optional> unwrapExceptions; + public Optional> unwrapExceptions; /** * SmallRye GraphQL UI configuration */ @ConfigItem @ConfigDocSection - SmallRyeGraphQLUIConfig ui; - + public SmallRyeGraphQLUIConfig ui; } diff --git a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLConfigMapping.java b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLConfigMapping.java similarity index 98% rename from extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLConfigMapping.java rename to extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLConfigMapping.java index 5b90af7a70817..2eedffe9e10ed 100644 --- a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLConfigMapping.java +++ b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLConfigMapping.java @@ -1,4 +1,4 @@ -package io.quarkus.smallrye.graphql.deployment; +package io.quarkus.smallrye.graphql.runtime; import java.util.Collections; import java.util.HashMap; diff --git a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLUIConfig.java b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLUIConfig.java similarity index 86% rename from extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLUIConfig.java rename to extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLUIConfig.java index f90f7aef7f132..325a07d530537 100644 --- a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLUIConfig.java +++ b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLUIConfig.java @@ -1,4 +1,4 @@ -package io.quarkus.smallrye.graphql.deployment; +package io.quarkus.smallrye.graphql.runtime; import io.quarkus.runtime.annotations.ConfigGroup; import io.quarkus.runtime.annotations.ConfigItem; @@ -12,12 +12,12 @@ public class SmallRyeGraphQLUIConfig { * By default, this URL will be resolved as a path relative to `${quarkus.http.non-application-root-path}`. */ @ConfigItem(defaultValue = "graphql-ui") - String rootPath; + public String rootPath; /** * Always include the UI. By default this will only be included in dev and test. * Setting this to true will also include the UI in Prod */ @ConfigItem(defaultValue = "false") - boolean alwaysInclude; + public boolean alwaysInclude; } diff --git a/extensions/smallrye-graphql/runtime/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor b/extensions/smallrye-graphql/runtime/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor new file mode 100644 index 0000000000000..8474e48c5d856 --- /dev/null +++ b/extensions/smallrye-graphql/runtime/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor @@ -0,0 +1 @@ +io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLConfigMapping