blb-ventures / strawberry-django-plus

Enhanced Strawberry GraphQL integration with Django
MIT License
179 stars 47 forks source link

Add description to enums from django choices #217

Closed camflan closed 1 year ago

camflan commented 1 year ago

Adds descriptions to enum values so users can query a more useful enum defintion,


query TestEnumQuery {
    enumData: __type(name: "UserRoleEnum") {
      name
      enumValues {
        name
        description
      }
    }
}

yields,

{
  enumData: [
     { name: "ADMIN", description: "Site administrator" },
     { name: "MEMBER", description: "Registered user who can modify their own data." }
  ]
}
bellini666 commented 1 year ago

Btw, if you are into client introspection, strawberry-resources might interest you as well

codecov-commenter commented 1 year ago

Codecov Report

Merging #217 (7118de1) into main (19ab9cf) will increase coverage by 0.26%. The diff coverage is 100.00%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main     #217      +/-   ##
==========================================
+ Coverage   90.31%   90.57%   +0.26%     
==========================================
  Files          45       46       +1     
  Lines        4337     4372      +35     
==========================================
+ Hits         3917     3960      +43     
+ Misses        420      412       -8     
Impacted Files Coverage Δ
strawberry_django_plus/types.py 81.61% <100.00%> (+6.06%) :arrow_up:
tests/conftest.py 100.00% <100.00%> (ø)
tests/test_generated_enum_choices.py 100.00% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

camflan commented 1 year ago

Awesome! :)

Just need to fix the lint test errors that failed. You can check those on your local environment by doing pre-commit install and then pre-commit run -a

Weird! Pre-commit ran and passed during pre-commit without errors 🤷 . I'll fix it up 👍