In python, typing.Union can be merged
a = Union[Test, Test0]
b = Union[Test1, Test2]
c = Union[a, b]
c == Union[Test, Test0, Test1, Test2]
Being able to merge StrawberryUnion's when creating a union with strawberry.union would be helpful in some cases and should be fairly cheap to implement
Example implementation in my project that adds that functionality by wrapping strawberry.union
def union(
name: str,
types: Tuple[Type, ...],
*args,
description: str = None,
) -> StrawberryUnion:
expanded_types = []
for _type in types:
if hasattr(_type, "__origin__") and _type.__origin__ == Union:
expanded_types.extend(_type.__args__)
elif isinstance(_type, StrawberryUnion):
expanded_types.extend(_type.types)
else:
expanded_types.append(_type)
return strawberry.union(
name=name,
types=tuple(expanded_types),
*args,
description=description
)
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too