Pass extra kwargs down the meta chain

This commit is contained in:
Jonathan Kim 2020-06-27 18:19:42 +01:00
parent bf034ca85f
commit 2bd3e61c6b
2 changed files with 15 additions and 2 deletions

View File

@ -20,12 +20,14 @@ class ObjectTypeOptions(BaseOptions):
class ObjectTypeMeta(BaseTypeMeta): class ObjectTypeMeta(BaseTypeMeta):
def __new__(cls, name, bases, namespace): def __new__(cls, name, bases, namespace, **kwargs):
# We create this type, to then overload it with the dataclass attrs # We create this type, to then overload it with the dataclass attrs
class InterObjectType: class InterObjectType:
pass pass
base_cls = super().__new__(cls, name, (InterObjectType,) + bases, namespace) base_cls = super().__new__(
cls, name, (InterObjectType,) + bases, namespace, **kwargs
)
if base_cls._meta: if base_cls._meta:
fields = [ fields = [
( (

View File

@ -295,3 +295,14 @@ def test_objecttype_meta_with_annotations():
schema = Schema(query=Query) schema = Schema(query=Query)
assert schema is not None assert schema is not None
def test_objecttype_meta_arguments():
class MyInterface(Interface):
foo = String()
class MyType(ObjectType, interfaces=[MyInterface]):
bar = String()
assert MyType._meta.interfaces == [MyInterface]
assert list(MyType._meta.fields.keys()) == ["foo", "bar"]