strawberry-graphql / strawberry-django

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

feat: Add ValidationError code to OperationMessage #358

Closed zvyn closed 10 months ago

zvyn commented 10 months ago

Description

Extends the OperationMessage by a code attribute that is set to the ValidationError.code if available.

I changed the test project to apply Djangos default validation in order to test that error codes used by Django internally are passed through as expected. This had the side-effect of turning a datetime object into a date object in an otherwise unrelated test.

Types of Changes

Issues Fixed or Closed by This PR

Checklist

bellini666 commented 10 months ago

This had the side-effect of turning a datetime object into a date object in an otherwise unrelated test.

Oh, I know what happened. The field is a DateField, but the argument was typed as datetime. It is actually a bug in the test that your change identified because you called .full_clean() on the model.

It is harmless though and I'll fix it later :)

bellini666 commented 10 months ago

@zvyn there's just a small pyright issue that needs to be fixed, then it can be merged

zvyn commented 10 months ago

@bellini666 thanks for the review! I'll take a look at the pyright issue later today

codecov-commenter commented 10 months ago

Codecov Report

Patch coverage: 66.66% and no project coverage change.

Comparison is base (2a2723c) 87.99% compared to head (5bcdebf) 87.99%. Report is 2 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #358 +/- ## ======================================= Coverage 87.99% 87.99% ======================================= Files 33 33 Lines 2940 2941 +1 ======================================= + Hits 2587 2588 +1 Misses 353 353 ``` | [Files Changed](https://app.codecov.io/gh/strawberry-graphql/strawberry-graphql-django/pull/358?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=strawberry-graphql) | Coverage Δ | | |---|---|---| | [strawberry\_django/fields/types.py](https://app.codecov.io/gh/strawberry-graphql/strawberry-graphql-django/pull/358?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=strawberry-graphql#diff-c3RyYXdiZXJyeV9kamFuZ28vZmllbGRzL3R5cGVzLnB5) | `86.63% <50.00%> (+0.06%)` | :arrow_up: | | [strawberry\_django/mutations/fields.py](https://app.codecov.io/gh/strawberry-graphql/strawberry-graphql-django/pull/358?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=strawberry-graphql#diff-c3RyYXdiZXJyeV9kamFuZ28vbXV0YXRpb25zL2ZpZWxkcy5weQ==) | `86.16% <100.00%> (ø)` | |

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