Skip to content

Commit 00db74f

Browse files
fix: python11 Union using | syntax in PydanticInputObjectType
1 parent e966ce0 commit 00db74f

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

graphene_pydantic/inputobjecttype.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,9 @@ def construct_fields(
4545

4646
fields = {}
4747
for name, field in fields_to_convert:
48-
declared_type = getattr(field, "annotation", None)
4948

50-
# Ignore Union types from Input. Refer https://github.com/graphql/graphql-spec/issues/488
51-
if isinstance(declared_type, UnionType) or (
52-
hasattr(declared_type, "__origin__") and declared_type.__origin__ == T.Union
53-
):
54-
continue
49+
if isinstance(getattr(field, "annotation", None), UnionType):
50+
field.annotation = T.Union[getattr(field, "annotation", None).__args__]
5551

5652
converted = convert_pydantic_input_field(
5753
field, registry, parent_type=obj_type, model=model

0 commit comments

Comments
 (0)