Skip to content

Commit f29fe5c

Browse files
committed
Fixed inheritance from abstract types. Fixed #84
1 parent a1519fc commit f29fe5c

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

graphene/core/classtypes/objecttype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
def is_objecttype(cls):
1313
if not issubclass(cls, ObjectType):
1414
return False
15-
return not cls._meta.interface
15+
return not(cls._meta.abstract or cls._meta.interface)
1616

1717

1818
class ObjectTypeOptions(FieldsOptions):

graphene/core/classtypes/tests/test_objecttype.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,30 @@ class Thing(Human, Pet):
8787
assert Thing._meta.type_name == 'Thing'
8888
assert Thing._meta.description == 'Thing union description'
8989
assert Thing.my_attr
90+
91+
92+
def test_object_type_not_union_if_abstract():
93+
schema = Schema()
94+
95+
class Query1(ObjectType):
96+
field1 = String()
97+
98+
class Meta:
99+
abstract = True
100+
101+
class Query2(ObjectType):
102+
field2 = String()
103+
104+
class Meta:
105+
abstract = True
106+
107+
class Query(Query1, Query2):
108+
'''Query description'''
109+
my_attr = True
110+
111+
object_type = schema.T(Query)
112+
assert issubclass(Query, ObjectType)
113+
assert Query._meta.type_name == 'Query'
114+
assert Query._meta.description == 'Query description'
115+
assert isinstance(object_type, GraphQLObjectType)
116+
assert list(Query._meta.fields_map.keys()) == ['field1', 'field2']

0 commit comments

Comments
 (0)