union

Creates a new named Union type.

Signature:

def union(
name: str,
types: Collection[Type[Any]] | None = None,
description: str | None = None,
directives: Iterable[object] = (),
) -> StrawberryUnion:
...

Parameters:

  1. name:

    The GraphQL name of the Union type.

    Type
    str
  2. types:

    The types that the Union can be. (Deprecated, use Annotated[U, strawberry.union("Name")] instead)

    Type
    Collection[Type[Any]] | None
    Default
    None
  3. description:

    The GraphQL description of the Union type.

    Type
    str | None
    Default
    None
  4. directives:

    The directives to attach to the Union type.

    Type
    Iterable[object]
    Default
    ()