PermissionExtension
Handles permissions for a field.
Instantiate this as a field extension with all of the permissions you want to apply.
Note: Currently, this is automatically added to the field, when using field.permission_classes
This is deprecated behaviour, please manually add the extension to field.extensions
Constructor:
Initialize the permission extension.
Signature:
Parameters:
-
permissions:
List of permissions to apply.
- Type
-
List[BasePermission]
-
use_directives:
If True, add schema directives to the field.
- Type
-
bool
- Default
-
True
-
fail_silently:
If True, return None or [] instead of raising an exception. This is only valid for optional or list fields.
- Type
-
bool
- Default
-
False
Methods:
-
apply
Applies all of the permission directives to the schema and sets up silent permissions.
Signature:
Parameters:
-
field:
- Type
-
StrawberryField
-
-
resolve
Checks if the permission should be accepted and raises an exception if not.
Signature:
Parameters:
-
next_:
- Type
-
SyncExtensionResolver
-
source:
- Type
-
Any
-
info:
- Type
-
Info
-
kwargs:
- Type
-
Dict[str, Any]
- Default
-
{}
-
-
resolve_async
Signature:
Parameters:
-
next_:
- Type
-
AsyncExtensionResolver
-
source:
- Type
-
Any
-
info:
- Type
-
Info
-
kwargs:
- Type
-
Dict[str, Any]
- Default
-
{}
-
Attributes:
-
permissions:
-
fail_silently:
-
return_empty_list:
-
use_directives:
-
supports_sync:
Whether this extension can be resolved synchronously or not.
The Permission extension always supports async checking using await_maybe, but only supports sync checking if there are no async permissions.
- Type
-
bool