mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-17 03:50:44 +03:00
Fixed inheritance from abstract types. Fixed #84
This commit is contained in:
parent
a1519fc271
commit
f29fe5c8fd
|
@ -12,7 +12,7 @@ from .uniontype import UnionType
|
||||||
def is_objecttype(cls):
|
def is_objecttype(cls):
|
||||||
if not issubclass(cls, ObjectType):
|
if not issubclass(cls, ObjectType):
|
||||||
return False
|
return False
|
||||||
return not cls._meta.interface
|
return not(cls._meta.abstract or cls._meta.interface)
|
||||||
|
|
||||||
|
|
||||||
class ObjectTypeOptions(FieldsOptions):
|
class ObjectTypeOptions(FieldsOptions):
|
||||||
|
|
|
@ -87,3 +87,30 @@ def test_object_type_union():
|
||||||
assert Thing._meta.type_name == 'Thing'
|
assert Thing._meta.type_name == 'Thing'
|
||||||
assert Thing._meta.description == 'Thing union description'
|
assert Thing._meta.description == 'Thing union description'
|
||||||
assert Thing.my_attr
|
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']
|
||||||
|
|
Loading…
Reference in New Issue
Block a user