connection
Annotate a property or a method to create a relay connection field.
Relay connections are mostly used for pagination purposes. This decorator helps creating a complete relay endpoint that provides default arguments and has a default implementation for the connection slicing.
Note that when setting a resolver to this field, it is expected for this resolver to return an iterable of the expected node type, not the connection itself. That iterable will then be paginated accordingly. So, the main use case for this is to provide a filtered iterable of nodes by using some custom filter arguments.
Signature:
Parameters:
-
graphql_type:
The type of the nodes in the connection. This is used to determine the type of the edges and the node field in the connection.
- Type
-
Type[Connection[NodeType]] | None
- Default
-
None
-
resolver:
The resolver for the connection. This is expected to return an iterable of the expected node type.
- 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.
- Type
-
bool
- Default
-
False
-
description:
The GraphQL description of the field.
- Type
-
str | None
- Default
-
None
-
permission_classes:
The permission classes to apply to the field.
- Type
-
List[Type[BasePermission]] | None
- Default
-
None
-
deprecation_reason:
The deprecation reason of the field.
- Type
-
str | None
- Default
-
None
-
default:
The default value of the field.
- Type
-
Any
- Default
-
dataclasses.MISSING
-
default_factory:
The default factory of the field.
- Type
-
Callable[..., object] | object
- Default
-
dataclasses.MISSING
-
metadata:
The metadata of the field.
- Type
-
Mapping[Any, Any] | None
- Default
-
None
-
directives:
The directives to apply to the field.
- Type
-
Sequence[object] | None
- Default
-
()
-
extensions:
The extensions to apply to the field.
- Type
-
List[FieldExtension]
- Default
-
()
-
init:
Used only for type checking purposes.
- Type
-
Literal[True, False, None]
- Default
-
None