Option to always "use_list" and not make relay Connections#257
Option to always "use_list" and not make relay Connections#257Ckk3 merged 8 commits intostrawberry-graphql:mainfrom
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideIntroduces an always_use_list flag to StrawberrySQLAlchemyMapper allowing users to default to list-based relationship fields instead of relay connections. 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.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/strawberry_sqlalchemy_mapper/mapper.py:678` </location>
<code_context>
def connection_resolver_for(
self, relationship: RelationshipProperty, use_list=False
) -> Callable[..., Awaitable[Any]]:
"""
Return an async field resolver for the given relationship that
returns a Connection instead of an array of objects.
This resolver also handles pagination arguments (first, after, last, before) that are
passed from the GraphQL query to the database query.
"""
relationship_resolver = self.relationship_resolver_for(relationship)
if relationship.uselist and not (use_list or self.always_use_list):
return self.make_connection_wrapper_resolver(
relationship_resolver,
relationship,
)
else:
return relationship_resolver
</code_context>
<issue_to_address>
**suggestion (code-quality):** Simplify logical expression using De Morgan identities ([`de-morgan`](https://docs.sourcery.ai/Reference/Default-Rules/refactorings/de-morgan/))
```suggestion
if relationship.uselist and not use_list and not self.always_use_list:
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Thanks for adding the Here's a preview of the changelog: Added a new optional constructor parameter to always use lists instead of relay Connections for relationships. Defaults to False, maintaining current functionality. If set to True, all relationships will be handled as lists. Example: |
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
|
Thanks for your contribuition, @gabor-lbl , I hope to review it in this weekend! |
Ckk3
left a comment
There was a problem hiding this comment.
Thanks for your contribution, @gabor-lbl
If you can't find time to do the comments please tell me that I will continue from here.
… instead of None. Updated README.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #257 +/- ##
==========================================
+ Coverage 92.31% 92.47% +0.15%
==========================================
Files 19 19
Lines 2395 2445 +50
Branches 188 188
==========================================
+ Hits 2211 2261 +50
Misses 98 98
Partials 86 86 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #257 will not alter performanceComparing Summary
|
…ted tests for mixed relationships
… class names for Employee and Department
|
Thanks for contributing to Strawberry! 🎉 You've been invited to join You can also request a free sticker by filling this form: https://forms.gle/dmnfQUPoY5gZbVT67 And don't forget to join our discord server: https://strawberry.rocks/discord 🔥 |

Description
I added an optional constructor parameter to always use lists for relationships and not make relay Connections. This way users who don't use Connections don't have to add
__use_list__to every model.Types of Changes
Issues Fixed or Closed by This PR
Checklist
toxto run... will continue to look into this)(I'm using it in my project.)
Summary by Sourcery
Add optional always_use_list parameter to StrawberrySQLAlchemyMapper to default relationship fields to lists and bypass Relay Connection creation.
New Features:
Enhancements: