def test_union_optional_with_or_operator():
    """Verify that the `|` operator is supported when annotating unions as
    optional in schemas.
    """

    @strawberry.type
    class Cat:
        name: str

    @strawberry.type
    class Dog:
        name: str

    with pytest.deprecated_call(
        match="Passing types to `strawberry.union` is deprecated"
    ):
        animal_union = strawberry.union("Animal", (Cat, Dog))

    @strawberry.type
    class Query:
        @strawberry.field
        def animal(self) -> animal_union | None:
            return None

    schema = strawberry.Schema(query=Query)
    query = """{
        animal {
            __typename
        }
    }"""

    result = schema.execute_sync(query, root_value=Query())

    assert not result.errors
    assert result.data["animal"] is None
Verify that the `|` operator is supported when annotating unions as
    optional in schemas.
    
tests/schema/test_union_deprecated.py