strawberry.type

Annotates a class as a GraphQL type.

Similar to dataclasses.dataclass , but with additional functionality for defining GraphQL types.

Returns:

The class.

Signature:

def type(
cls: T | None = None,
name: str | None = None,
is_input: bool = False,
is_interface: bool = False,
description: str | None = None,
directives: Sequence[object] | None = (),
extend: bool = False,
) -> T | Callable[[T], T]:
...

Parameters:

  1. name:

    The name of the GraphQL type.

    Type
    str | None
    Default
    None
  2. is_input:

    Whether the class is an input type. Used internally, use @strawerry.input instead of passing this flag.

    Type
    bool
    Default
    False
  3. is_interface:

    Whether the class is an interface. Used internally, use @strawerry.interface instead of passing this flag.

    Type
    bool
    Default
    False
  4. description:

    The description of the GraphQL type.

    Type
    str | None
    Default
    None
  5. directives:

    The directives of the GraphQL type.

    Type
    Sequence[object] | None
    Default
    ()
  6. extend:

    Whether the class is extending an existing type.

    Type
    bool
    Default
    False