Set any arbitrary meta fields onto the meta instance

This commit is contained in:
Jonathan Kim 2020-03-15 18:25:40 +00:00
parent 60a9609b9a
commit 12d8ef813c
2 changed files with 14 additions and 0 deletions

View File

@ -40,6 +40,11 @@ class BaseType(SubclassWithMeta):
return
_meta.name = name or cls.__name__
_meta.description = description or trim_docstring(cls.__doc__)
# Set all extra arguments onto the meta class as well
for key, value in _kwargs.items():
setattr(_meta, key, value)
_meta.freeze()
cls._meta = _meta
super(BaseType, cls).__init_subclass_with_meta__()

View File

@ -275,3 +275,12 @@ def test_objecttype_meta_with_annotations():
schema = Schema(query=Query)
assert schema is not None
def test_objecttype_meta_extra_fields():
class Query(ObjectType):
class Meta:
name = "MyQuery"
foo = "bar"
assert Query._meta.foo == "bar"