Open Speedy1991 opened 3 months ago
Btw. in another MR it would be awesome to have some binary operation possible, e.g.:
strawberry.field(permissions=[(FeatureRequired(feature_1) | FeatureRequired(feature_2)) & MemberRoleRequired])
I'm +1 for this! I also think it might be worth renaming permission_classes to permissions, since we don't just allow classes after implementing this PR
and yes, there's a PR for supporting boolean operators :) will check that soon
A littlebit offtopic, but maybe it would be possible to annotate type
too? But I think this should be a follow up feature request after this one is implemented :)
e.g.: @type(permissions=[A(), B()]
These permissions will be applied to all fields with &
condition?
Feature Request Type
Description
Currently it is not possible to use instances of PermissionClasses, leading to lots of boilerplate.
Usecase: I want to check for specific features, like this:
@strawberry.field(permission_classes=[FeatureRequired(feature_1), FeatureRequired(feature_2)]
This does not work, because permission_classes only takes classes and will be instanciated here.
To "fix" this the Typing must be fixed List[Type[BasePermission]] to something like
List[Type[BasePermission] | BasePermission]]
and the code snippet here:needs some inspection like this:
with this changes I also would suggest to refactor the
permission_classes
name topermissions
+ deprecating thepermission_classes
argument onstrawberry.field
Upvote & Fund