strawberry.mutation

Annotates a method or property as a GraphQL mutation.

Returns:

The field object.

Signature:

def mutation(
resolver: _RESOLVER_TYPE[Any] | None = None,
name: str | None = None,
description: str | None = None,
permission_classes: List[Type[BasePermission]] | None = None,
deprecation_reason: str | None = None,
default: Any = dataclasses.MISSING,
default_factory: Callable[..., object] | object = dataclasses.MISSING,
metadata: Mapping[Any, Any] | None = None,
directives: Sequence[object] | None = (),
extensions: List[FieldExtension] | None = None,
graphql_type: Any | None = None,
init: Literal[True, False, None] = None,
) -> Any:
...

Parameters:

  1. resolver:

    The resolver for the field. It can be a sync or async function.

    Type
    _RESOLVER_TYPE[Any] | None
    Default
    None
  2. name:

    The GraphQL name of the field.

    Type
    str | None
    Default
    None
  3. description:

    The GraphQL description of the field.

    Type
    str | None
    Default
    None
  4. permission_classes:

    The permission classes required to access the field.

    Type
    List[Type[BasePermission]] | None
    Default
    None
  5. deprecation_reason:

    The deprecation reason for the field.

    Type
    str | None
    Default
    None
  6. default:

    The default value for the field.

    Type
    Any
    Default
    dataclasses.MISSING
  7. default_factory:

    The default factory for the field.

    Type
    Callable[..., object] | object
    Default
    dataclasses.MISSING
  8. metadata:

    The metadata for the field.

    Type
    Mapping[Any, Any] | None
    Default
    None
  9. directives:

    The directives for the field.

    Type
    Sequence[object] | None
    Default
    ()
  10. extensions:

    The extensions for the field.

    Type
    List[FieldExtension] | None
    Default
    None
  11. 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
  12. 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