strawberry-graphql / strawberry-django

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

Fix `_perm_cache` processing #498

Closed vecchp closed 3 months ago

vecchp commented 3 months ago

Description

It appears this line in utils/query.py is not checking cached permissions properly.

In my codebase the _perm_cache comes up as a set of strings which then causes an exception

user_perms: Set[str] = {p.codename for p in perm_cache}
                          ^^^^^^^^^^
AttributeError: 'str' object has no attribute 'codename'

Looking at the django codebase I think this line confirms that the perm_cache is indeed a set of strings. This seems to be the same behavior going back to django 0.90.

Also a previous PR https://github.com/strawberry-graphql/strawberry-django/pull/428, seemed to have run into the same issue but for some reason it was closed.

Types of Changes

Issues Fixed or Closed by This PR

*

Checklist

codecov-commenter commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 87.97%. Comparing base (67433e6) to head (e4b067d).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #498 +/- ## ========================================== - Coverage 87.98% 87.97% -0.02% ========================================== Files 37 37 Lines 3180 3184 +4 ========================================== + Hits 2798 2801 +3 - Misses 382 383 +1 ```

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