Skip to content

add missing page_info / cursors for Association Proxy logic #241

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

Merged
merged 17 commits into from
May 13, 2025

Conversation

Ckk3
Copy link
Contributor

@Ckk3 Ckk3 commented Apr 25, 2025

Note: This PR supersedes #232 because the original contributor did not allow edits from maintainers, and we needed to add additional tests to proceed with the merge. All credits remain to the original author for the core fix.

Original description:

Description

association_proxy_resolver_for has a few code blocks that were not updated for the relay changes. Association proxy mapping would fail due do constructors missing either page_info or cursor args.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Issues Fixed or Closed by This PR

  • N/a

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

I haven't added tests as it looks like this code is originally untested.

Summary by Sourcery

Bug Fixes:

  • Fix association proxy mapping failures due to missing page_info or cursor arguments in constructors.

Summary by Sourcery

Bug Fixes:

  • Ensure association proxy resolvers return valid relay connections, including page_info and edge cursor details, even for empty results.

Summary by Sourcery

Fix association proxy resolvers to always return valid relay connections with correct page_info and cursor fields, including for empty results, and add comprehensive tests for association proxy logic.

Bug Fixes:

  • Fix association proxy mapping failures by ensuring relay connections include page_info and cursor fields, even for empty results.

Enhancements:

  • Improve error messages for unsupported association proxy targets and related exceptions.

Documentation:

  • Add release notes describing the patch and its impact.

Tests:

  • Add extensive tests for association proxy behavior, including edge cases and nullable relationships.

Copy link
Contributor

sourcery-ai bot commented Apr 25, 2025

Reviewer's Guide

This PR fixes association proxy mapping failures by ensuring that relay connection constructors always receive the required page_info and cursor arguments, even for empty results. It refactors resolver logic for association proxies, improves error messages for unsupported targets, and adds comprehensive tests for association proxy behavior, including edge cases. Minor code style and test improvements are also included.

File-Level Changes

Change Details Files
Fix association proxy relay connection construction to always provide page_info and cursor.
  • Refactor resolver logic to use a shared _resolve_connection_edges method for constructing relay connections.
  • Ensure page_info and cursor fields are always set, even for empty connections.
  • Update association proxy resolver to handle None and empty cases gracefully.
src/strawberry_sqlalchemy_mapper/mapper.py
Improve error messages for unsupported association proxy targets and related exceptions.
  • Clarify and expand exception messages for unsupported association proxies and descriptors.
src/strawberry_sqlalchemy_mapper/exc.py
Add comprehensive tests for association proxy logic, including edge cases and relay connection output.
  • Add new test_association_proxy.py with extensive tests for association proxy mapping, relay connection output, and error handling.
  • Update conftest.py to provide a mapper fixture for tests.
  • Refactor test_mapper.py for code style and assertion improvements.
tests/test_association_proxy.py
tests/conftest.py
tests/test_mapper.py
Document the patch and its impact on relay connection handling.
  • Add RELEASE.md describing the patch and its effect on association proxy relay connections.
RELEASE.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov-commenter
Copy link

codecov-commenter commented May 10, 2025

Codecov Report

Attention: Patch coverage is 97.61905% with 7 lines in your changes missing coverage. Please review.

Project coverage is 89.94%. Comparing base (e19bdb8) to head (cfc8c6c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #241      +/-   ##
==========================================
+ Coverage   86.05%   89.94%   +3.88%     
==========================================
  Files          16       17       +1     
  Lines        1671     1939     +268     
  Branches      136      141       +5     
==========================================
+ Hits         1438     1744     +306     
+ Misses        174      123      -51     
- Partials       59       72      +13     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

codspeed-hq bot commented May 10, 2025

CodSpeed Performance Report

Merging #241 will not alter performance

Comparing Ckk3:tyler-fixrelay (cfc8c6c) with main (e19bdb8)

Summary

✅ 1 untouched benchmarks

@Ckk3
Copy link
Contributor Author

Ckk3 commented May 11, 2025

@sourcery-ai review

@Ckk3
Copy link
Contributor Author

Ckk3 commented May 11, 2025

@sourcery-ai summary

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 @Ckk3 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Documentation: 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 and I'll use the feedback to improve your reviews.

@Ckk3 Ckk3 marked this pull request as ready for review May 11, 2025 23:05
@botberry
Copy link
Member

botberry commented May 11, 2025

Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:


Ensure association proxy resolvers return valid relay connections, including page_info and edge cursor details, even for empty results.

Thanks to https://github.com/tylernisonoff for the original PR.

@Ckk3 Ckk3 requested review from novag and removed request for novag May 11, 2025 23:06
@Ckk3
Copy link
Contributor Author

Ckk3 commented May 11, 2025

Ready for review, @patrick91 @bellini666 @fruitymedley !

@Ckk3 Ckk3 requested a review from fruitymedley May 11, 2025 23:06
@Ckk3
Copy link
Contributor Author

Ckk3 commented May 11, 2025

@sourcery-ai review

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 @Ckk3 - 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

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 and I'll use the feedback to improve your reviews.

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 @Ckk3 - 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

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 and I'll use the feedback to improve your reviews.

@Ckk3 Ckk3 merged commit 74c41b7 into strawberry-graphql:main May 13, 2025
19 checks passed
@Ckk3
Copy link
Contributor Author

Ckk3 commented May 13, 2025

Thanks @tylernisonoff 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants