strawberry-graphql / strawberry-django

Strawberry GraphQL Django extension
https://strawberry.rocks/docs/django
MIT License
406 stars 117 forks source link

fix: Fix specialized connection aliases missing filters/ordering #547

Closed bellini666 closed 3 months ago

bellini666 commented 3 months ago

When retrieving the strawberry django type, we need to make sure to resolve any LazyType and also to consider specialized type vars for aliases to get the NodeType from them.

This also bumps the minimum strawberry version to 0.234.2 as the fix in that release is required for this change.

Without this change, Author.books would not contain filters and order arguments

Fix https://github.com/strawberry-graphql/strawberry-django/issues/535

Thanks @Eraldo for reporting and creating an MRE that helped to identify the issue

Summary by Sourcery

This pull request fixes a bug where specialized connection aliases were missing filters and ordering arguments by resolving LazyType and considering specialized type vars for aliases. New tests were added to ensure the correctness of these changes.

sourcery-ai[bot] commented 3 months ago

Reviewer's Guide by Sourcery

This pull request addresses an issue where specialized connection aliases were missing filters and ordering arguments. The changes ensure that when retrieving the strawberry Django type, any LazyType is resolved, and specialized type variables for aliases are considered to get the NodeType. This fix ensures that fields like Author.books will now include filters and order arguments.

File-Level Changes

Files Changes
tests/relay/lazy/b.py
tests/relay/lazy/a.py
tests/relay/lazy/models.py
Added new test files and models to verify the fix for specialized connection aliases including filters and ordering arguments.

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](https://sourcery.ai/dashboard): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.
Eraldo commented 3 months ago

@bellini666 Awesome! This really helps me with my migration. 🙏 👏 Works perfectly! 👍