-
-
Notifications
You must be signed in to change notification settings - Fork 916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix error thrown for invalid operation name #3106
Conversation
result.Errors[0].InnerException.ShouldBeOfType<InvalidOperationException>(); | ||
result.Errors[0].InnerException.Message.ShouldBe($"Query does not contain operation '{operationName}'."); | ||
result.Errors[0].ShouldBeOfType<InvalidOperationError>(); | ||
result.Errors[0].Message.ShouldBe("Query does not contain operation '" + operationName + "'."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check InnerException
for null
?
@@ -65,7 +64,7 @@ public static IServiceProvider CurrentServiceProvider | |||
{ | |||
var method = _currentMethod.Value; | |||
return method == null || !_diAdapters.TryGetValue(method, out var stack) || stack == null || stack.Count == 0 | |||
? throw new InvalidOperationError("Attempt to access IServiceProvider out of prepared DependencyInjection context.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops
@@ -147,7 +147,7 @@ public virtual async Task<ExecutionResult> ExecuteAsync(ExecutionOptions options | |||
|
|||
if (operation == null) | |||
{ | |||
throw new InvalidOperationException($"Query does not contain operation '{options.OperationName}'."); | |||
throw new InvalidOperationError($"Query does not contain operation '{options.OperationName}'."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move metrics.SetOperationName(operation?.Name);
after this check.
Codecov Report
@@ Coverage Diff @@
## master #3106 +/- ##
==========================================
+ Coverage 84.31% 84.34% +0.02%
==========================================
Files 362 362
Lines 15884 15884
Branches 2580 2579 -1
==========================================
+ Hits 13393 13397 +4
+ Misses 1875 1871 -4
Partials 616 616
Continue to review full report at Codecov.
|
When a request is executed with an operation name that is not listed in the document, a "client" (validation) error should be returned to the caller with friendly description, rather than a "server" error being thrown which triggers the unhandled exception delegate and returns a masked error to the caller.