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

fix: fix optimized nested connections failing to access totalCount #553

Merged
merged 2 commits into from
Jun 12, 2024

Conversation

bellini666
Copy link
Member

@bellini666 bellini666 commented Jun 12, 2024

When resolving the connection from cache, we were missing setting nodes in it 🤦‍♂️

We do have a test that was passing with this, but MPTT triggered the issue. The issue was probably happening to corner cases as well

Used #551 as a base for the reproduction, but adjusted it to avoid depending on python 3.9

Fix #552

@bellini666 bellini666 self-assigned this Jun 12, 2024
Copy link
Contributor

sourcery-ai bot commented Jun 12, 2024

Reviewer's Guide by Sourcery

This pull request addresses an issue with nested MPTT (Modified Preorder Tree Traversal) connections when trying to access the totalCount in a GraphQL query. The changes include a fix in the resolve_connection method in strawberry_django/relay.py and the addition of several test files to ensure the correctness of the fix.

File-Level Changes

Files Changes
tests/relay/mptt/test_nested_children.py
tests/relay/mptt/test_lazy_annotations.py
Added tests to verify the correctness of nested MPTT connections and lazy type annotations in the schema.
tests/relay/mptt/a.py
tests/relay/mptt/b.py
tests/relay/mptt/models.py
Defined models and types for MPTTAuthor and MPTTBook with necessary connections and filters.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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: 3 issues found
  • 🟢 Security: all looks good
  • 🟡 Testing: 2 issues found
  • 🟢 Complexity: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

strawberry_django/relay.py Show resolved Hide resolved
strawberry_django/relay.py Show resolved Hide resolved
strawberry_django/relay.py Show resolved Hide resolved
tests/relay/mptt/test_nested_children.py Show resolved Hide resolved
tests/relay/mptt/test_nested_children.py Show resolved Hide resolved
@bellini666 bellini666 changed the title fix: fix nested MPTT connections when trying to access totalCount fix: fix optimized nested connections failing to access totalCount Jun 12, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jun 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.71%. Comparing base (015621c) to head (98d9c9c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #553      +/-   ##
==========================================
+ Coverage   88.67%   88.71%   +0.03%     
==========================================
  Files          41       41              
  Lines        3524     3527       +3     
==========================================
+ Hits         3125     3129       +4     
+ Misses        399      398       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bellini666 bellini666 merged commit 3481e8d into main Jun 12, 2024
22 checks passed
@bellini666 bellini666 deleted the fix_mptt branch June 12, 2024 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: MPTT relations compatibility
3 participants