From b0892d500066858a0ef1f376a2baa3b019fc508b Mon Sep 17 00:00:00 2001 From: Phillip Kruger Date: Mon, 13 Sep 2021 11:48:09 +0200 Subject: [PATCH] Change the default for `printDatafetcherException` to true in Dev Mode Signed-off-by: Phillip Kruger --- .../deployment/SmallRyeGraphQLConfig.java | 6 +++--- .../deployment/SmallRyeGraphQLProcessor.java | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLConfig.java b/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLConfig.java index 58609a93d7fee..c9512c1ef40b4 100644 --- a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLConfig.java +++ b/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLConfig.java @@ -91,10 +91,10 @@ public class SmallRyeGraphQLConfig { Optional defaultErrorMessage; /** - * Print the data fetcher exception to the log file. + * Print the data fetcher exception to the log file. Default `true` in dev and test mode, default `false` in prod. */ - @ConfigItem(defaultValue = "false") - boolean printDataFetcherException; + @ConfigItem + Optional printDataFetcherException; /** * Make the schema available over HTTP. 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 8665c4a4f9018..0721b153785cb 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 @@ -399,6 +399,22 @@ private Set getAllReferenceClasses(Reference reference) { return classes; } + @BuildStep + void printDataFetcherExceptionInDevMode(SmallRyeGraphQLConfig graphQLConfig, + LaunchModeBuildItem launchMode, + BuildProducer systemProperties) { + + // User did not set this explisitly + if (!graphQLConfig.printDataFetcherException.isPresent()) { + if (launchMode.getLaunchMode().isDevOrTest()) { + systemProperties.produce(new SystemPropertyBuildItem(ConfigKey.PRINT_DATAFETCHER_EXCEPTION, TRUE)); + } + } else { + systemProperties.produce(new SystemPropertyBuildItem(ConfigKey.PRINT_DATAFETCHER_EXCEPTION, + String.valueOf(graphQLConfig.printDataFetcherException.get()))); + } + } + // Services Integrations @BuildStep