Skip to content

Commit

Permalink
Merge pull request quarkusio#20602 from radcortez/fix-20494
Browse files Browse the repository at this point in the history
Moved SmallRyeGraphQLConfigMapping to the runtime dependency
  • Loading branch information
phillip-kruger authored Oct 11, 2021
2 parents 7a1e58d + 2efb1d8 commit d2d1ca2
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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"));
}
}
4 changes: 4 additions & 0 deletions extensions/smallrye-graphql/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-schema-builder</artifactId>
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-cdi</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,154 +1,154 @@
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 {

/**
* The rootPath under which queries will be served. Default to graphql
* 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<Boolean> metricsEnabled;
public Optional<Boolean> metricsEnabled;

/**
* Enable tracing. By default this will be enabled if the tracing extension is added.
*/
@ConfigItem(name = "tracing.enabled")
Optional<Boolean> tracingEnabled;
public Optional<Boolean> tracingEnabled;

/**
* Enable validation. By default this will be enabled if the Hibernate Validator extension is added.
*/
@ConfigItem(name = "validation.enabled")
Optional<Boolean> validationEnabled;
public Optional<Boolean> 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<Boolean> httpGetEnabled;
public Optional<Boolean> 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<Boolean> httpPostQueryParametersEnabled;
public Optional<Boolean> 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.
* By default none will be included. Examples of valid values include
* [exception,classification,code,description,validationErrorType,queryPath]
*/
@ConfigItem
Optional<List<String>> errorExtensionFields;
public Optional<List<String>> 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<List<String>> showRuntimeExceptionMessage;
public Optional<List<String>> 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<List<String>> hideCheckedExceptionMessage;
public Optional<List<String>> hideCheckedExceptionMessage;

/**
* The default error message that will be used for hidden exception messages.
* Defaults to "Server Error"
*/
@ConfigItem
Optional<String> defaultErrorMessage;
public Optional<String> defaultErrorMessage;

/**
* Print the data fetcher exception to the log file. Default `true` in dev and test mode, default `false` in prod.
*/
@ConfigItem
Optional<Boolean> printDataFetcherException;
public Optional<Boolean> 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<List<String>> unwrapExceptions;
public Optional<List<String>> unwrapExceptions;

/**
* SmallRye GraphQL UI configuration
*/
@ConfigItem
@ConfigDocSection
SmallRyeGraphQLUIConfig ui;

public SmallRyeGraphQLUIConfig ui;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.smallrye.graphql.deployment;
package io.quarkus.smallrye.graphql.runtime;

import java.util.Collections;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLConfigMapping

0 comments on commit d2d1ca2

Please sign in to comment.