Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for generic unions #3515

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
8 changes: 6 additions & 2 deletions strawberry/schema/schema_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,9 +856,13 @@

if isinstance(graphql_type, GraphQLInputObjectType):
raise InvalidTypeInputForUnion(graphql_type)
assert isinstance(graphql_type, GraphQLObjectType)
assert isinstance(graphql_type, GraphQLObjectType | GraphQLUnionType)

graphql_types.append(graphql_type)
if isinstance(graphql_type, GraphQLUnionType):
enoua5 marked this conversation as resolved.
Show resolved Hide resolved
# merge child types
enoua5 marked this conversation as resolved.
Show resolved Hide resolved
graphql_types += list(graphql_type.types)

Check warning on line 863 in strawberry/schema/schema_converter.py

View check run for this annotation

Codecov / codecov/patch

strawberry/schema/schema_converter.py#L863

Added line #L863 was not covered by tests
enoua5 marked this conversation as resolved.
Show resolved Hide resolved
else:
graphql_types.append(graphql_type)

graphql_union = GraphQLUnionType(
name=union_name,
Expand Down
Loading