From e028a7da99b79a9821dc86cfabcec256cf7a8cd1 Mon Sep 17 00:00:00 2001 From: Muhammed Aldulaimi Date: Sat, 9 Nov 2024 12:27:59 +0300 Subject: [PATCH 1/3] Override Union meta --- graphene/types/union.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphene/types/union.py b/graphene/types/union.py index b7c5dc62..277ed794 100644 --- a/graphene/types/union.py +++ b/graphene/types/union.py @@ -56,7 +56,7 @@ def __init_subclass_with_meta__(cls, types=None, **options): isinstance(types, (list, tuple)) and len(types) > 0 ), f"Must provide types for Union {cls.__name__}." - _meta = UnionOptions(cls) + _meta = options.pop("_meta", UnionOptions(cls)) _meta.types = types super(Union, cls).__init_subclass_with_meta__(_meta=_meta, **options) From 1406b8f9609b142a7a6575badbfb2380327f7d47 Mon Sep 17 00:00:00 2001 From: Muhammed Aldulaimi Date: Sat, 9 Nov 2024 13:00:17 +0300 Subject: [PATCH 2/3] Add _meta explicitely --- graphene/types/union.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/graphene/types/union.py b/graphene/types/union.py index 277ed794..809ed01b 100644 --- a/graphene/types/union.py +++ b/graphene/types/union.py @@ -51,12 +51,14 @@ class Query(ObjectType): """ @classmethod - def __init_subclass_with_meta__(cls, types=None, **options): + def __init_subclass_with_meta__(cls, types=None, _meta=None, **options): assert ( isinstance(types, (list, tuple)) and len(types) > 0 ), f"Must provide types for Union {cls.__name__}." - _meta = options.pop("_meta", UnionOptions(cls)) + if _meta is None: + _meta = UnionOptions(cls) + _meta.types = types super(Union, cls).__init_subclass_with_meta__(_meta=_meta, **options) From a90852a7af87673dd0385de3721b9fa82e3bcf10 Mon Sep 17 00:00:00 2001 From: Erik Wrede Date: Sat, 9 Nov 2024 17:26:50 +0100 Subject: [PATCH 3/3] chore: code style --- graphene/types/union.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphene/types/union.py b/graphene/types/union.py index 809ed01b..3d10418e 100644 --- a/graphene/types/union.py +++ b/graphene/types/union.py @@ -56,7 +56,7 @@ def __init_subclass_with_meta__(cls, types=None, _meta=None, **options): isinstance(types, (list, tuple)) and len(types) > 0 ), f"Must provide types for Union {cls.__name__}." - if _meta is None: + if not _meta: _meta = UnionOptions(cls) _meta.types = types