Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions graphene_sqlalchemy/tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,15 @@ def test_object_type():
assert issubclass(Human, ObjectType)
assert list(Human._meta.fields.keys()) == ['id', 'headline', 'reporter_id', 'reporter', 'pub_date']
assert is_node(Human)


def test_abstract_subclass():
registry = Registry()

class AbstractSubclass(SQLAlchemyObjectType):
class Meta:
registry = registry
abstract = True

assert issubclass(AbstractSubclass, SQLAlchemyObjectType)
assert len(registry._registry) == 0
3 changes: 2 additions & 1 deletion graphene_sqlalchemy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ class SQLAlchemyObjectTypeMeta(ObjectTypeMeta):
def __new__(cls, name, bases, attrs):
# Also ensure initialization is only performed for subclasses of Model
# (excluding Model class itself).
if not is_base_type(bases, SQLAlchemyObjectTypeMeta):
if not is_base_type(bases, SQLAlchemyObjectTypeMeta) or \
('Meta' in attrs and getattr(attrs['Meta'], 'abstract', False)):
return type.__new__(cls, name, bases, attrs)

options = Options(
Expand Down