File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 9
9
from graphene .relay import Node
10
10
11
11
from .. import registry
12
+ from ..filter import DjangoFilterConnectionField
12
13
from ..types import DjangoObjectType , DjangoObjectTypeOptions
13
14
from .models import Article as ArticleModel
14
15
from .models import Reporter as ReporterModel
@@ -580,3 +581,28 @@ class Query(ObjectType):
580
581
}
581
582
"""
582
583
)
584
+
585
+
586
+ @with_local_registry
587
+ def test_django_objecttype_name_connection_propagation ():
588
+ class Reporter (DjangoObjectType ):
589
+ class Meta :
590
+ model = ReporterModel
591
+ name = "CustomReporterName"
592
+ filter_fields = ["email" ]
593
+ interfaces = (Node ,)
594
+
595
+ class Query (ObjectType ):
596
+ reporter = Node .Field (Reporter )
597
+ reporters = DjangoFilterConnectionField (Reporter )
598
+
599
+ assert Reporter ._meta .name == "CustomReporterName"
600
+ schema = str (Schema (query = Query ))
601
+
602
+ assert "type CustomReporterName implements Node {" in schema
603
+ assert "type CustomReporterNameConnection {" in schema
604
+ assert "type CustomReporterNameEdge {" in schema
605
+
606
+ assert "type Reporter implements Node {" not in schema
607
+ assert "type ReporterConnection {" not in schema
608
+ assert "type ReporterEdge {" not in schema
Original file line number Diff line number Diff line change @@ -239,7 +239,7 @@ def __init_subclass_with_meta__(
239
239
connection_class = Connection
240
240
241
241
connection = connection_class .create_type (
242
- "{}Connection" .format (cls .__name__ ), node = cls
242
+ "{}Connection" .format (options . get ( "name" ) or cls .__name__ ), node = cls
243
243
)
244
244
245
245
if connection is not None :
You can’t perform that action at this time.
0 commit comments