mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-25 02:54:06 +03:00
Fix Connection/Edge naming and add unit test (#1012)
Co-authored-by: Thomas Leonard <thomas@loftorbital.com>
This commit is contained in:
parent
55769e814f
commit
11dbde3bea
|
@ -9,6 +9,7 @@ from graphene import Connection, Field, Interface, ObjectType, Schema, String
|
||||||
from graphene.relay import Node
|
from graphene.relay import Node
|
||||||
|
|
||||||
from .. import registry
|
from .. import registry
|
||||||
|
from ..filter import DjangoFilterConnectionField
|
||||||
from ..types import DjangoObjectType, DjangoObjectTypeOptions
|
from ..types import DjangoObjectType, DjangoObjectTypeOptions
|
||||||
from .models import Article as ArticleModel
|
from .models import Article as ArticleModel
|
||||||
from .models import Reporter as ReporterModel
|
from .models import Reporter as ReporterModel
|
||||||
|
@ -580,3 +581,28 @@ class TestDjangoObjectType:
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
|
@ -239,7 +239,7 @@ class DjangoObjectType(ObjectType):
|
||||||
connection_class = Connection
|
connection_class = Connection
|
||||||
|
|
||||||
connection = connection_class.create_type(
|
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:
|
if connection is not None:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user