Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Connection/Edge naming and add unit test #1012

Merged
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
26 changes: 26 additions & 0 deletions graphene_django/tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from graphene.relay import Node

from .. import registry
from ..filter import DjangoFilterConnectionField
from ..types import DjangoObjectType, DjangoObjectTypeOptions
from .models import Article as ArticleModel
from .models import Reporter as ReporterModel
Expand Down Expand Up @@ -580,3 +581,28 @@ class Query(ObjectType):
}
"""
)


@with_local_registry
def test_django_objecttype_name_connection_propagation():
class Reporter(DjangoObjectType):
class Meta:
model = ReporterModel
name = "CustomReporterName"
filter_fields = ["email"]
interfaces = (Node,)

class Query(ObjectType):
reporter = Node.Field(Reporter)
reporters = DjangoFilterConnectionField(Reporter)

assert Reporter._meta.name == "CustomReporterName"
schema = str(Schema(query=Query))

assert "type CustomReporterName implements Node {" in schema
assert "type CustomReporterNameConnection {" in schema
assert "type CustomReporterNameEdge {" in schema

assert "type Reporter implements Node {" not in schema
assert "type ReporterConnection {" not in schema
assert "type ReporterEdge {" not in schema
2 changes: 1 addition & 1 deletion graphene_django/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def __init_subclass_with_meta__(
connection_class = Connection

connection = connection_class.create_type(
"{}Connection".format(cls.__name__), node=cls
"{}Connection".format(options.get("name") or cls.__name__), node=cls
)

if connection is not None:
Expand Down