From 3ed7bf6362f59b14dcf5b22bb63d920a926ba181 Mon Sep 17 00:00:00 2001 From: Muhammed Al-Dulaimi Date: Sat, 9 Nov 2024 20:17:42 +0300 Subject: [PATCH] chore: Make Union meta overridable (#1583) This PR makes the Union Options configurable, similar to how it works with ObjectTypes --------- Co-authored-by: Erik Wrede --- 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 b7c5dc62..3d10418e 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 = UnionOptions(cls) + if not _meta: + _meta = UnionOptions(cls) + _meta.types = types super(Union, cls).__init_subclass_with_meta__(_meta=_meta, **options)