You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Validation does work in my current GraphQL implementation.
As proposed in the docs I added a validation rule to the first arg of the first field of my root mutation. I also added validation "cascade" to the second arg that is an input object.
See the following example:
RootMutation:
type: "object"
config:
description: RootMutation type
fieldsDefaultAccess: "@=hasRole('ROLE_USER')"
updateUser:
description: Updates a user
type: "User!"
access: "@=hasRole('ROLE_USER') && isGranted('user_access', args['id'])"
args:
id:
description: ID of the user
type: "ID!"
validation:
- Email: []
user:
description: Data of the user to update
type: "UpdateUser!"
validation: cascade
UpdateUser:
type: "input-object"
config:
description: Input object to update a user
fields:
displayName:
description: Display name of the user
type: "String!"
validation:
- Length:
min: 5
max: 10
I can see the validation rules are basically processed. When I add a constraint that does not exist, it says:
In TypeBuilder.php line 632:
Constraint class 'Symfony\Component\Validator\Constraints\WrongEmail' doesn't exist.
I can also see the constraints are added to the auto generated type classes in app/var/cache/test/overblog/graphql-bundle/__definitions__:
However, I cannot see the Email validator actually being called. I can put in any value as the user ID. And I cannot see the Length constraint being checked for display name either. Any string value is accepted.
The only thing I get is a deprecation notice:
Remaining indirect deprecation notices (2)
2x: Creation of dynamic property GraphQL\Type\Definition\InputObjectField::$validation is deprecated
2x in MutationServiceTest::testUpdatingUser from App\Tests
I tried to debug the the validation process and set break points in different places like in Overblog\GraphQLBundle\Validator\InputValidator, but those lines are never crossed.
Did I miss anything in the docs? Does the validation have to be activated somehow?
Can somebody please confirm this is a bug? Or tell me a good place where to set a debugger breakpoint so I can investigate why validation takes not place in my project?
Thank you!
The text was updated successfully, but these errors were encountered:
ThomasCooks
changed the title
Validation not working
Validation not working [Update: with Resolver Maps]
Jun 1, 2023
Validation does work in my current GraphQL implementation.
As proposed in the docs I added a validation rule to the first arg of the first field of my root mutation. I also added validation "cascade" to the second arg that is an input object.
See the following example:
I can see the validation rules are basically processed. When I add a constraint that does not exist, it says:
I can also see the constraints are added to the auto generated type classes in
app/var/cache/test/overblog/graphql-bundle/__definitions__
:However, I cannot see the Email validator actually being called. I can put in any value as the user ID. And I cannot see the Length constraint being checked for display name either. Any string value is accepted.
The only thing I get is a deprecation notice:
I tried to debug the the validation process and set break points in different places like in
Overblog\GraphQLBundle\Validator\InputValidator
, but those lines are never crossed.Did I miss anything in the docs? Does the validation have to be activated somehow?
Can somebody please confirm this is a bug? Or tell me a good place where to set a debugger breakpoint so I can investigate why validation takes not place in my project?
Thank you!
The text was updated successfully, but these errors were encountered: