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 <erikwrede@users.noreply.github.com>
This commit is contained in:
Muhammed Al-Dulaimi 2024-11-09 20:17:42 +03:00 committed by GitHub
parent ccae7364e5
commit 3ed7bf6362
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -51,12 +51,14 @@ class Union(UnmountedType, BaseType):
"""
@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)