Skip to content

Commit 725feb1

Browse files
committed
Add connection
1 parent 631513f commit 725feb1

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

graphene_sqlalchemy/tests/test_types.py

+10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from graphene import (Dynamic, Field, GlobalID, Int, List, Node, NonNull,
66
ObjectType, Schema, String)
7+
from graphene.relay import Connection
78

89
from ..converter import convert_sqlalchemy_composite
910
from ..fields import (SQLAlchemyConnectionField,
@@ -46,6 +47,15 @@ class Meta:
4647
assert reporter == reporter_node
4748

4849

50+
def test_connection():
51+
class ReporterType(SQLAlchemyObjectType):
52+
class Meta:
53+
model = Reporter
54+
interfaces = (Node,)
55+
56+
assert issubclass(ReporterType.connection, Connection)
57+
58+
4959
def test_sqlalchemy_default_fields():
5060
@convert_sqlalchemy_composite.register(CompositeFullName)
5161
def convert_composite_class(composite, registry):

graphene_sqlalchemy/types.py

+2
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ def __init_subclass_with_meta__(
325325
_meta.connection = connection
326326
_meta.id = id or "id"
327327

328+
cls.connection = connection # Public way to get the connection
329+
328330
super(SQLAlchemyObjectType, cls).__init_subclass_with_meta__(
329331
_meta=_meta, interfaces=interfaces, **options
330332
)

0 commit comments

Comments
 (0)