strawberry.enum

Annotates an Enum class a GraphQL enum.

GraphQL enums only have names, while Python enums have names and values, Strawberry will use the names of the Python enum as the names of the GraphQL enum values.

Returns:

The decorated Enum class.

Signature:

def enum(
cls: EnumType | None = None,
name: str | None = None,
description: str | None = None,
directives: Iterable[object] = (),
) -> EnumType | Callable[[EnumType], EnumType]:
...

Parameters:

  1. name:

    The name of the GraphQL enum.

    Type
    str | None
    Default
    None
  2. description:

    The description of the GraphQL enum.

    Type
    str | None
    Default
    None
  3. directives:

    The directives to attach to the GraphQL enum.

    Type
    Iterable[object]
    Default
    ()