strawberry-graphql / strawberry-django

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

feat: Add support for auto mapping of ArrayFields #567

Closed bellini666 closed 3 months ago

bellini666 commented 3 months ago

Fix #200

Summary by Sourcery

This pull request introduces support for auto mapping of ArrayFields in Django models, including handling for both single-dimensional and multi-dimensional arrays. It also adds corresponding tests to ensure the correct type resolution and functionality.

sourcery-ai[bot] commented 3 months ago

Reviewer's Guide by Sourcery

This pull request adds support for auto mapping of ArrayFields in Django models. The implementation includes importing ArrayField from django.contrib.postgres.fields, adding a helper function _resolve_array_field_type to handle the type resolution of ArrayFields, and updating the resolve_model_field_type function to incorporate this new functionality. Additionally, new tests have been added to verify the correct handling of both single and nested ArrayFields.

File-Level Changes

Files Changes
tests/fields/test_types.py
strawberry_django/fields/types.py
Implemented support for auto mapping of ArrayFields and added corresponding tests to ensure correct type resolution for both single and nested ArrayFields.

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.
codecov-commenter commented 3 months ago

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.88%. Comparing base (db5ca05) to head (dfaa5e7). Report is 1 commits behind head on main.

Files Patch % Lines
strawberry_django/fields/types.py 91.66% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #567 +/- ## ========================================== + Coverage 88.85% 88.88% +0.03% ========================================== Files 41 41 Lines 3544 3545 +1 ========================================== + Hits 3149 3151 +2 + Misses 395 394 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.