-
-
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
Add RequestServices to ValidationContext #3051
Conversation
I would keep it as non-null. Writing non-standard rules is not a frequent work. Standard rules should not suffer because of this forcing callers to check public AuthorizationError(ASTNode? node, ValidationContext context, string message, AuthorizationResult result, OperationType? operationType = null)
: base(context.Document.Source, "6.1.1", message, node == null ? Array.Empty<ASTNode>() : new ASTNode[] { node }) 6.1.1 points to the paragraph with generic explanation of validation process. |
Then we should have an alternate way of adding a validation rule without a number. There is no practical reason why a number should be required. It is not part of the spec, and we already have codes, also not part of the spec. Why should a custom validation rule require a number? Clearly we have set up the system for custom validation rules, and clearly those will not typically have a number from the spec assigned to it. I can add constructors that mirrors those of
I seriously don't know what you're talking about. The serializers already check |
I'm not sure what other people do, but this is the second validation rule I have written in the last couple weeks. Neither had to do with anything to do with the spec. Could I have punched a string in the field? Sure. But that is not the intent of the field. |
Codecov Report
@@ Coverage Diff @@
## master #3051 +/- ##
==========================================
+ Coverage 83.61% 83.66% +0.04%
==========================================
Files 360 360
Lines 15698 15710 +12
Branches 2557 2557
==========================================
+ Hits 13126 13143 +17
+ Misses 1898 1893 -5
Partials 674 674
Continue to review full report at Codecov.
|
Co-authored-by: Ivan Maximov <sungam3r@yandex.ru>
…raphql-dotnet/graphql-dotnet into requestservices_validationrule
I tried to write a validation rule today and was quite surprised to find that I could not access the scoped service provider provided to the request.
Also, to add an error to the validation context, you have to add an instance of
ValidationError
, which currently requires thatNumber
be provided. This is merely a NRT error, asNumber
is not actually required. Note thatNumber
is defined as the following:So obviously there is no "paragraph number from the official specification" for custom validation errors. Hence
Number
should not be required for custom validation errors anyway.