strawberry.field
Annotates a method or property as a GraphQL field.
Returns:
The field.
Signature:
Parameters:
-
resolver:
The resolver for the field. This can be a function or a
StrawberryResolver
.- Type
-
_RESOLVER_TYPE[Any] | None
- Default
-
None
-
name:
The GraphQL name of the field.
- Type
-
str | None
- Default
-
None
-
is_subscription:
Whether the field is a subscription field.
- Type
-
bool
- Default
-
False
-
description:
The GraphQL description of the field.
- Type
-
str | None
- Default
-
None
-
permission_classes:
The permission classes required to access the field.
- Type
-
List[Type[BasePermission]] | None
- Default
-
None
-
deprecation_reason:
The deprecation reason for the field.
- Type
-
str | None
- Default
-
None
-
default:
The default value for the field.
- Type
-
Any
- Default
-
dataclasses.MISSING
-
default_factory:
The default factory for the field.
- Type
-
Callable[..., object] | object
- Default
-
dataclasses.MISSING
-
metadata:
The metadata for the field.
- Type
-
Mapping[Any, Any] | None
- Default
-
None
-
directives:
The directives for the field.
- Type
-
Sequence[object] | None
- Default
-
()
-
extensions:
The extensions for the field.
- Type
-
List[FieldExtension] | None
- Default
-
None
-
graphql_type:
The GraphQL type for the field, useful when you want to use a different type in the resolver than the one in the schema.
- Type
-
Any | None
- Default
-
None
-
init:
This parameter is used by PyRight to determine whether this field is added in the constructor or not. It is not used to change any behavior at the moment.
- Type
-
Literal[True, False, None]
- Default
-
None