Skip to content

Commit

Permalink
Added Option to throw exceptions unhandled (#225)
Browse files Browse the repository at this point in the history
Co-authored-by: Patrick Spiegel <[email protected]>
  • Loading branch information
Weeb6279 and Patrick Spiegel authored Nov 17, 2021
1 parent ad00ba3 commit 8329d9d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/GraphQL.Conventions/Adapters/Engine/GraphQLEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class GraphQLEngine
private IErrorTransformation _errorTransformation = new DefaultErrorTransformation();

private bool _includeFieldDescriptions;
private bool _throwUnhandledExceptions;

private bool _includeFieldDeprecationReasons;

Expand Down Expand Up @@ -208,6 +209,12 @@ public GraphQLEngine PrintFieldDescriptions(bool include = true)
return this;
}

public GraphQLEngine ThrowUnhandledExceptions(bool throwUnhandledExceptions = true)
{
_throwUnhandledExceptions = throwUnhandledExceptions;
return this;
}

public GraphQLEngine PrintFieldDeprecationReasons(bool include = true)
{
_includeFieldDeprecationReasons = include;
Expand Down Expand Up @@ -297,12 +304,13 @@ internal async Task<ExecutionResult> ExecuteAsync(
EnableMetrics = enableProfiling,
UserContext = new Dictionary<string, object>()
{
{ typeof(IUserContext).FullName ?? nameof(IUserContext), userContext},
{ typeof(IDependencyInjector).FullName ?? nameof(IDependencyInjector), dependencyInjector},
{ typeof(IUserContext).FullName ?? nameof(IUserContext), userContext },
{ typeof(IDependencyInjector).FullName ?? nameof(IDependencyInjector), dependencyInjector },
},
ValidationRules = validationRules.Any() ? validationRules : null,
ComplexityConfiguration = complexityConfiguration,
CancellationToken = cancellationToken,
ThrowOnUnhandledException = _throwUnhandledExceptions,
};

if (listeners != null)
Expand Down

0 comments on commit 8329d9d

Please sign in to comment.