strawberry-graphql / strawberry-django

Strawberry GraphQL Django extension
MIT License
391 stars 115 forks source link

Generated fields type resolution #565

Closed Mapiarz closed 1 day ago

Mapiarz commented 3 days ago

I added support for field type resolution for Django 5 GeneratedFields. For a generated field, the output_field is mandatory, and this is what I'm using to determine the strawberry field type.

Extended existing test about field type resolution that is backwards compatible with Django <5. Did not modify the project dependencies.

Summary by Sourcery

This pull request introduces support for resolving field types for Django 5 GeneratedFields by utilizing the output_field attribute. It also extends existing tests to cover this new functionality while maintaining compatibility with earlier Django versions.

sourcery-ai[bot] commented 3 days ago

Reviewer's Guide by Sourcery

This pull request adds support for field type resolution for Django 5 GeneratedFields. The changes include importing GeneratedField, updating type resolution logic to use model_field.output_field, and extending tests to ensure backward compatibility with Django versions prior to 5.

File-Level Changes

Files Changes
strawberry_django/fields/base.py
strawberry_django/fields/types.py
Added support for Django 5 GeneratedField by importing it and updating type resolution logic to use model_field.output_field.

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://app.sourcery.ai): - 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.