Fixed inheritance from abstract types. Fixed #84

This commit is contained in:
Syrus Akbary 2016-01-21 12:34:42 -08:00
parent a1519fc271
commit f29fe5c8fd
2 changed files with 28 additions and 1 deletions

View File

@ -12,7 +12,7 @@ from .uniontype import UnionType
def is_objecttype(cls):
if not issubclass(cls, ObjectType):
return False
return not cls._meta.interface
return not(cls._meta.abstract or cls._meta.interface)
class ObjectTypeOptions(FieldsOptions):

View File

@ -87,3 +87,30 @@ def test_object_type_union():
assert Thing._meta.type_name == 'Thing'
assert Thing._meta.description == 'Thing union description'
assert Thing.my_attr
def test_object_type_not_union_if_abstract():
schema = Schema()
class Query1(ObjectType):
field1 = String()
class Meta:
abstract = True
class Query2(ObjectType):
field2 = String()
class Meta:
abstract = True
class Query(Query1, Query2):
'''Query description'''
my_attr = True
object_type = schema.T(Query)
assert issubclass(Query, ObjectType)
assert Query._meta.type_name == 'Query'
assert Query._meta.description == 'Query description'
assert isinstance(object_type, GraphQLObjectType)
assert list(Query._meta.fields_map.keys()) == ['field1', 'field2']