-
Notifications
You must be signed in to change notification settings - Fork 222
feature/validation #536
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
feature/validation #536
Conversation
* Little refactoring in ArgumentsValidator and ValidationNode
* Roll back the change on NewObject class * Remove test for ExpressionFunction class * Fix TypeGenerator
* Replace png with svg * Correct formatting
* Rollback changes in composer.json
src/ExpressionLanguage/ExpressionFunction/GraphQL/Relay/IdFetcherCallback.php
Show resolved
Hide resolved
src/ExpressionLanguage/ExpressionFunction/GraphQL/Relay/MutateAndGetPayloadCallback.php
Show resolved
Hide resolved
src/ExpressionLanguage/ExpressionFunction/GraphQL/Relay/ResolveSingleInputCallback.php
Show resolved
Hide resolved
@murtukov validator injection is good. Also the option not to throw. I had similar feature in mind for the Reason: There are few opinionated way handling user input errors. Not all of them are handled via Would it be possible to directly inject errors via expression, so |
Co-Authored-By: Jeremiah VALERIE <[email protected]>
…ID.php Co-Authored-By: Jeremiah VALERIE <[email protected]>
…feature/validation_v.0.13
…ID.php Co-Authored-By: Jeremiah VALERIE <[email protected]>
Co-Authored-By: Jeremiah VALERIE <[email protected]>
* Refactor the ExpressionValidator class * Rename '$FQCN' to '$fqcn'
…feature/validation_v.0.13
* Refactor the ExpressionValidator class * Rename '$FQCN' to '$fqcn' * Fix type hints
Throw an exception if the `cascade` validation option is set to a scalar type.
- Move the test for non-existent constraint - Create test for the option `cascade` on scalar types - Update the ExpectedErrors class according to the new error shape -
Documentation:
Please first read the documentation completely. If some sections are not clear let me know, I'll try to rewrite them in more clear words.
Think about the titles, maybe some of them should be changed. There is a section called How does it work?. Is the name ok or should we rename it to something like Internals? Any other suggestions?
Architechture:
When you call
graphql:compile
, the Generator creates definition classes. Currently all resolvers always look something like this:there is no extra code, just calling
$globalVariable->get('...')->resolve([...])
.I modified the generator classes so, that when you add validation to your configuration and call
graphql:compile
, the Generator creates an extra code in the resolver of your definition classes, something like this:This will be done by the
generateExtraCode()
method declared in thelib\
folder asabstract
, so that the code under thelib\
folder remains generic and it's implementation locates under thesrc\
directory.The main reason why I decided to make it all by Generator is because of its performance:
InputValidator
class will be instantiated only when you call a resolver.So it doesn't create any services and therefore creates no overhead.
The generator classes won't generate extra code if you dont declare the
validator
variable in the expression e.g.:if you have any thoughts about this solution, let me know.
Formatting of validation errors
It uses the built in feature Error handling to return validation errors to the client. I created a class
Overblog\GraphQLBundle\Validator\Formatter
to change the response for exceptions of classArgumentsValidationException
.Validators
All the validation logic is located under the
src\Validator
directory.Annotations and
ArgumentsTransformer
class.@Vincz I assume that the annotation feature is mainly your work. Currently my validator implementation works only for yaml configuration. I would like to also add support for annotations, but first I would like to discuss your implementation of the class
ArgumentsTransformer
with you , because it has it's own validation mechanism which conflicts with my implementation. I will create a separate issue for that, but for now I ask you to stop any further development of theArgumentsTransformer
. Maybe it will be removed or modified, to use this validation feature (depends on our discussion).I will edit and add new stuff to this comment during the discussion.