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
15 changes: 14 additions & 1 deletion graphene_django/tests/test_types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from mock import patch

from graphene import Interface, ObjectType, Schema
from graphene import Interface, ObjectType, Schema, Connection, String
from graphene.relay import Node

from .. import registry
Expand All @@ -17,11 +17,23 @@ class Meta:
model = ReporterModel


class ArticleConnection(Connection):
'''Article Connection'''
test = String()

def resolve_test():
return 'test'

class Meta:
abstract = True


class Article(DjangoObjectType):
'''Article description'''
class Meta:
model = ArticleModel
interfaces = (Node, )
connection_class = ArticleConnection


class RootQuery(ObjectType):
Expand Down Expand Up @@ -74,6 +86,7 @@ def test_schema_representation():
type ArticleConnection {
pageInfo: PageInfo!
edges: [ArticleEdge]!
test: String
}

type ArticleEdge {
Expand Down
8 changes: 6 additions & 2 deletions graphene_django/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class DjangoObjectType(ObjectType):
@classmethod
def __init_subclass_with_meta__(cls, model=None, registry=None, skip_registry=False,
only_fields=(), exclude_fields=(), filter_fields=None, connection=None,
use_connection=None, interfaces=(), **options):
connection_class=None, use_connection=None, interfaces=(), **options):
assert is_valid_django_model(model), (
'You need to pass a valid Django Model in {}.Meta, received "{}".'
).format(cls.__name__, model)
Expand All @@ -71,7 +71,11 @@ def __init_subclass_with_meta__(cls, model=None, registry=None, skip_registry=Fa

if use_connection and not connection:
# We create the connection automatically
connection = Connection.create_type('{}Connection'.format(cls.__name__), node=cls)
if not connection_class:
connection_class = Connection

connection = connection_class.create_type(
'{}Connection'.format(cls.__name__), node=cls)

if connection is not None:
assert issubclass(connection, Connection), (
Expand Down