-
-
Notifications
You must be signed in to change notification settings - Fork 147
filters in mutation default required, and add setting ALLOW_MUTATIONS_WITHOUT_FILTERS to control #755
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
Conversation
…_WITHOUT_FILTERS to control
Reviewer's GuideIntroduce a new ALLOW_MUTATIONS_WITHOUT_FILTERS setting (default false) to enforce required filters on Django mutations, update the filter argument logic to respect this flag, and adjust the test suite to include explicit filters in mutation calls and validate the new setting. Sequence Diagram: Filter Argument Optionality in MutationssequenceDiagram
title "Sequence Diagram: Filter Argument Optionality in Mutations"
participant ClientCode as Client Code (e.g., Strawberry framework)
participant FieldInstance as FieldInstance (self, in filters.py)
participant DjangoMutationBaseMod as DjangoMutationBase (type check)
participant Settings as strawberry_django_settings
ClientCode->>FieldInstance: call arguments()
FieldInstance->>FieldInstance: if (filters is not None and self.is_list)
activate FieldInstance
FieldInstance->>DjangoMutationBaseMod: isinstance(self, DjangoMutationBase)?
alt self is instance of DjangoMutationBase
FieldInstance->>Settings: strawberry_django_settings()
Settings-->>FieldInstance: settings_data (contains ALLOW_MUTATIONS_WITHOUT_FILTERS)
FieldInstance->>FieldInstance: is_optional_for_filters_arg = settings_data['ALLOW_MUTATIONS_WITHOUT_FILTERS']
else self is not instance of DjangoMutationBase
FieldInstance->>FieldInstance: is_optional_for_filters_arg = True
end
FieldInstance->>FieldInstance: arguments.append(FILTERS_ARG, filters, is_optional=is_optional_for_filters_arg)
deactivate FieldInstance
FieldInstance-->>ClientCode: list of arguments (with FILTERS_ARG optionality based on logic)
ER Diagram: Update to StrawberryDjangoSettingserDiagram
title "ER Diagram: Update to StrawberryDjangoSettings"
StrawberryDjangoSettings {
bool ALLOW_MUTATIONS_WITHOUT_FILTERS "New setting to control filter requirement in mutations (default: false)"
string other_existing_settings "Represents other pre-existing settings"
}
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @star2000 - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #755 +/- ##
==========================================
+ Coverage 89.00% 89.02% +0.01%
==========================================
Files 45 45
Lines 4303 4309 +6
==========================================
+ Hits 3830 3836 +6
Misses 473 473 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bellini666
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ty! :)
Description
This is to prevent front-end developers from accidentally modifying or deleting the entire table.
Types of Changes
Issues Fixed or Closed by This PR
close #751
Checklist
Summary by Sourcery
Enforce requiring filters in update and delete mutations by default to prevent unintended bulk operations, and provide a new configuration option to override this behavior.
Enhancements:
Tests: