strawberry-graphql/strawberry

Add support of permission_classes for type decorator

Opened this issue · 0 comments

Feature Request Type

  • Core functionality
  • Alteration (enhancement/optimization) of existing feature(s)
  • New behavior

Description

As the title describes, the strawberry.type decorator lacks the option to set global permission classes, making the code repetitive and highly verbose, improving also DX.

Making a whole query protected with the same permission would result like this:

Actual solution

@strawberry.type
class Query:
    user: str = strawberry.field(permission_classes=[IsAuthenticated])
    x1: str = strawberry.field(permission_classes=[IsAuthenticated])
    x2: str = strawberry.field(permission_classes=[IsAuthenticated])
    x3: str = strawberry.field(permission_classes=[IsAuthenticated])
    x4: str = strawberry.field(permission_classes=[IsAuthenticated]) 

Desired solution

@strawberry.type(permission_classes=[IsAuthenticated])
class Query:
    user: str
    x1: str
    x2: str
    x3: str

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar