Skip to content

Commit

Permalink
chore: Make Union meta overridable (#1583)
Browse files Browse the repository at this point in the history
This PR makes the Union Options configurable, similar to how it works with ObjectTypes
---------

Co-authored-by: Erik Wrede <[email protected]>
  • Loading branch information
that-one-arab and erikwrede authored Nov 9, 2024
1 parent ccae736 commit 3ed7bf6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions graphene/types/union.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 3ed7bf6

Please sign in to comment.