Skip to content
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

Update mutations.py to include full_clean parameter #701

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions strawberry_django/mutations/mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
DjangoMutationBase,
DjangoUpdateMutation,
)
from .types import FullCleanOptions

_T = TypeVar("_T")

Expand Down Expand Up @@ -257,6 +258,7 @@
extensions: list[FieldExtension] = (), # type: ignore
argument_name: Optional[str] = None,
handle_django_errors: Optional[bool] = None,
full_clean: bool | FullCleanOptions = True,

Check failure on line 261 in strawberry_django/mutations/mutations.py

View workflow job for this annotation

GitHub Actions / Typing

Alternative syntax for unions requires Python 3.10 or newer (reportGeneralTypeIssues)
) -> Any:
"""Create mutation for django input fields.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider documenting the purpose and behavior of the full_clean parameter, particularly the FullCleanOptions variant.

The parameter's ability to accept both boolean and FullCleanOptions suggests important functionality that should be explained in the docstring.

Suggested change
"""Create mutation for django input fields.
"""Create mutation for django input fields.
Args:
full_clean: Controls model validation behavior before saving.
When True (default), performs standard Django model validation.
When False, skips validation.
When FullCleanOptions is provided, allows fine-grained control over validation:
- exclude: List of fields to exclude from validation
- validate_unique: Whether to validate model uniqueness constraints
- validate_constraints: Whether to validate model constraints
"""


Expand Down Expand Up @@ -293,6 +295,7 @@
extensions=extensions or (),
argument_name=argument_name,
handle_django_errors=handle_django_errors,
full_clean=full_clean,
)


Expand All @@ -316,6 +319,7 @@
argument_name: Optional[str] = None,
handle_django_errors: Optional[bool] = None,
key_attr: Optional[str] = None,
full_clean: bool | FullCleanOptions = True,

Check failure on line 322 in strawberry_django/mutations/mutations.py

View workflow job for this annotation

GitHub Actions / Typing

Alternative syntax for unions requires Python 3.10 or newer (reportGeneralTypeIssues)
) -> Any:
"""Update mutation for django input fields.

Expand Down Expand Up @@ -352,6 +356,7 @@
argument_name=argument_name,
handle_django_errors=handle_django_errors,
key_attr=key_attr,
full_clean=full_clean,
)


Expand All @@ -375,6 +380,7 @@
argument_name: Optional[str] = None,
handle_django_errors: Optional[bool] = None,
key_attr: Optional[str] = None,
full_clean: bool | FullCleanOptions = True,

Check failure on line 383 in strawberry_django/mutations/mutations.py

View workflow job for this annotation

GitHub Actions / Typing

Alternative syntax for unions requires Python 3.10 or newer (reportGeneralTypeIssues)
) -> Any:
return DjangoDeleteMutation(
input_type=input_type,
Expand All @@ -395,4 +401,5 @@
argument_name=argument_name,
handle_django_errors=handle_django_errors,
key_attr=key_attr,
full_clean=full_clean,
)
Loading