File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -1007,3 +1007,47 @@ class Query(graphene.ObjectType):
1007
1007
1008
1008
result = schema .execute (query )
1009
1009
assert result .errors
1010
+
1011
+
1012
+ def test_should_resolve_get_queryset_connectionfields ():
1013
+ reporter_1 = Reporter .objects .create (
1014
+ first_name = "John" , last_name = "Doe" , email = "johndoe@example.com" , a_choice = 1
1015
+ )
1016
+ reporter_2 = CNNReporter .objects .create (
1017
+ first_name = "Some" ,
1018
+ last_name = "Guy" ,
1019
+ email = "someguy@cnn.com" ,
1020
+ a_choice = 1 ,
1021
+ reporter_type = 2 , # set this guy to be CNN
1022
+ )
1023
+
1024
+ class ReporterType (DjangoObjectType ):
1025
+ class Meta :
1026
+ model = Reporter
1027
+ interfaces = (Node ,)
1028
+
1029
+ @classmethod
1030
+ def get_queryset (cls , queryset , info ):
1031
+ return queryset .filter (reporter_type = 2 )
1032
+
1033
+ class Query (graphene .ObjectType ):
1034
+ all_reporters = DjangoConnectionField (ReporterType )
1035
+
1036
+ schema = graphene .Schema (query = Query )
1037
+ query = """
1038
+ query ReporterPromiseConnectionQuery {
1039
+ allReporters(first: 1) {
1040
+ edges {
1041
+ node {
1042
+ id
1043
+ }
1044
+ }
1045
+ }
1046
+ }
1047
+ """
1048
+
1049
+ expected = {"allReporters" : {"edges" : [{"node" : {"id" : "UmVwb3J0ZXJUeXBlOjI=" }}]}}
1050
+
1051
+ result = schema .execute (query )
1052
+ assert not result .errors
1053
+ assert result .data == expected
You can’t perform that action at this time.
0 commit comments