StrawberryField
Constructor:
Signature:
def __init__( self, python_name: str | None = None, graphql_name: str | None = None, type_annotation: StrawberryAnnotation | None = None, origin: Type | Callable | staticmethod | classmethod | None = None, is_subscription: bool = False, description: str | None = None, base_resolver: StrawberryResolver | None = None, permission_classes: List[Type[BasePermission]] = (), default: object = dataclasses.MISSING, default_factory: Callable[[], Any] | object = dataclasses.MISSING, metadata: Mapping[Any, Any] | None = None, deprecation_reason: str | None = None, directives: Sequence[object] = (), extensions: List[FieldExtension] = (),) -> None: ...
Parameters:
-
python_name:
- Type
-
str | None
- Default
-
None
-
graphql_name:
- Type
-
str | None
- Default
-
None
-
type_annotation:
- Type
-
StrawberryAnnotation | None
- Default
-
None
-
origin:
- Type
-
Type | Callable | staticmethod | classmethod | None
- Default
-
None
-
is_subscription:
- Type
-
bool
- Default
-
False
-
description:
- Type
-
str | None
- Default
-
None
-
base_resolver:
- Type
-
StrawberryResolver | None
- Default
-
None
-
permission_classes:
- Type
-
List[Type[BasePermission]]
- Default
-
()
-
default:
- Type
-
object
- Default
-
dataclasses.MISSING
-
default_factory:
- Type
-
Callable[[], Any] | object
- Default
-
dataclasses.MISSING
-
metadata:
- Type
-
Mapping[Any, Any] | None
- Default
-
None
-
deprecation_reason:
- Type
-
str | None
- Default
-
None
-
directives:
- Type
-
Sequence[object]
- Default
-
()
-
extensions:
- Type
-
List[FieldExtension]
- Default
-
()
Methods:
-
get_result
Calls the resolver defined for the StrawberryField.
If the field doesn’t have a resolver defined we default to using the default resolver specified in StrawberryConfig.
Signature:
def get_result(self,source: Any,info: Info | None,args: List[Any],kwargs: Any,) -> Awaitable[Any] | Any:...Parameters:
-
source:
- Type
-
Any
-
info:
- Type
-
Info | None
-
args:
- Type
-
List[Any]
-
kwargs:
- Type
-
Any
-
-
resolve_type
Signature:
def resolve_type(self, type_definition: StrawberryObjectDefinition | None = None) -> StrawberryType | Type[WithStrawberryObjectDefinition] | Literal[UNRESOLVED]:...Parameters:
-
type_definition:
- Type
-
StrawberryObjectDefinition | None
- Default
-
None
-
-
copy_with
Signature:
def copy_with(self, type_var_map: Mapping[str, StrawberryType | builtins.type]) -> Self:...Parameters:
-
type_var_map:
- Type
-
Mapping[str, StrawberryType | builtins.type]
-
Attributes:
-
type_annotation:
- Type
-
StrawberryAnnotation | None
-
default_resolver:
- Type
-
Callable[[Any, str], object]
-
graphql_name:
-
python_name:
- Type
-
str
-
description:
- Type
-
str | None
-
origin:
-
base_resolver:
- Type
-
StrawberryResolver | None
-
default_value:
-
is_subscription:
-
permission_classes:
- Type
-
List[Type[BasePermission]]
-
directives:
-
extensions:
- Type
-
List[FieldExtension]
-
deprecation_reason:
-
is_basic_field:
Returns a boolean indicating if the field is a basic field.
A “basic” field us a field that has no resolver or permission classes, i.e. it just returns the relevant attribute from the source object. If it is a basic field we can avoid constructing an
Info
object and running any permission checks in the resolver which improves performance.- Type
-
bool
-
arguments:
- Type
-
List[StrawberryArgument]
-
is_graphql_generic:
- Type
-
bool
-
type:
- Type
-
StrawberryType | Type[WithStrawberryObjectDefinition] | Literal[UNRESOLVED]
-
type_params:
- Type
-
List[TypeVar]
-
is_async:
- Type
-
bool