-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
fix(mutations): Refetch instances to optimize the return value #674
Conversation
Reviewer's Guide by SourceryThis PR optimizes mutation return values by refetching instances after mutations to ensure all fields (including annotated ones) are properly included in the response. The implementation adds a new Sequence diagram for refetching instances after mutationsequenceDiagram
participant User
participant Mutation as DjangoMutation
participant DB as Database
User->>Mutation: Request mutation (create/update/delete)
Mutation->>DB: Perform mutation
DB-->>Mutation: Return mutated instance(s)
Mutation->>Mutation: Call refetch(resolved, info)
Mutation->>DB: Refetch optimized instance(s)
DB-->>Mutation: Return optimized instance(s)
Mutation-->>User: Return optimized result
Class diagram for updated mutation classesclassDiagram
class DjangoMutationBase {
+refetch(resolved: _T, info: Info | None) _T
}
class DjangoCreateMutation {
+resolver(...)
+create(data: dict[str, Any], info: Info)
}
class DjangoUpdateMutation {
+resolver(...)
+instance_level_update(...)
+update(instance: models.Model | Iterable[models.Model], data: dict[str, Any])
}
class DjangoDeleteMutation {
+resolver(...)
+delete(instance: models.Model | Iterable[models.Model], data: dict[str, Any] | None)
}
DjangoCreateMutation --|> DjangoMutationBase
DjangoUpdateMutation --|> DjangoMutationBase
DjangoDeleteMutation --|> DjangoMutationBase
note for DjangoMutationBase "New refetch method added for optimization"
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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 @bellini666 - 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: 1 issue found
- 🟢 Complexity: 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 ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #674 +/- ##
==========================================
+ Coverage 88.94% 88.99% +0.04%
==========================================
Files 41 41
Lines 3737 3752 +15
==========================================
+ Hits 3324 3339 +15
Misses 413 413 ☔ View full report in Codecov by Sentry. |
Refetch instances after the mutation to make sure we optimize the result.
Without this,
annotated
fields would not exist in the return value and would fail to be returned.I'm also modifying a test to include an annotated field. Without this change applied it would fail.
Fix #635
Summary by Sourcery
Refetch instances after mutations to ensure annotated fields are included in the return value, addressing issue #635. Introduce a refetch method to optimize the retrieval of instances post-mutation. Add a test case to verify the inclusion of the 'isDelayed' field in the mutation response.
Bug Fixes:
annotate
and other query optimizations fail in mutations #635.Enhancements:
Tests: