If a nested field is updated via the parent field, a validation on the nested field should be performed, if some validators are provided on the django field.
Assuming we have a Parent model with some nested fields:
class Parent(models.Model);
foo_field = models.CharField()
class Child(models.Model):
url = models.URLField(validators=[validators.validate_url])
parent_field = models.ForeignKey(to=Parent, related_name="children")
We create some types and a create mutation:
@strawberry.type(Child, exclude=["parent_field"])
class Child:
id: auto
url: auto
@strawberry.input(Child)
class ChildInput(Child):
pass
@strawberry.type(Parent)
class Parent:
id: auto
foo_field: auto
children: List[Child]
@strawberry.input(Parent)
class ParentInput(Parent):
pass
@strawberry.type
class Mutation:
parent: Parent = mutations.create(types.ParentInput)
No matter which value is passed to the URL Field of the Child
, the validator is not executed.
Reason is that the update_m2m
method in resolvers.py does not execute a full_clean
on the respective object.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too