@@ -1130,6 +1130,7 @@ def test_should_have_next_page(graphene_settings):
1130
1130
graphene_settings .RELAY_CONNECTION_MAX_LIMIT = 4
1131
1131
reporters = [Reporter (** kwargs ) for kwargs in REPORTERS ]
1132
1132
Reporter .objects .bulk_create (reporters )
1133
+ db_reporters = Reporter .objects .all ()
1133
1134
1134
1135
class ReporterType (DjangoObjectType ):
1135
1136
class Meta :
@@ -1144,10 +1145,11 @@ class Query(graphene.ObjectType):
1144
1145
# See `arrayconnection.py::connection_from_list_slice`:
1145
1146
# has_next_page=isinstance(first, int) and end_offset < upper_bound
1146
1147
query = """
1147
- query AllReporters {
1148
- allReporters(first: 4 ) {
1148
+ query AllReporters($first: Int, $after: String) {
1149
+ allReporters(first: $first, after: $after ) {
1149
1150
pageInfo {
1150
1151
hasNextPage
1152
+ endCursor
1151
1153
}
1152
1154
edges {
1153
1155
node {
@@ -1158,11 +1160,26 @@ class Query(graphene.ObjectType):
1158
1160
}
1159
1161
"""
1160
1162
1161
- result = schema .execute (query )
1163
+ result = schema .execute (query , variable_values = dict ( first = 4 ) )
1162
1164
assert not result .errors
1163
1165
assert len (result .data ["allReporters" ]["edges" ]) == 4
1164
1166
assert result .data ["allReporters" ]["pageInfo" ]["hasNextPage" ]
1165
1167
1168
+ last_result = result .data ["allReporters" ]["pageInfo" ]["endCursor" ]
1169
+ result2 = schema .execute (query , variable_values = dict (first = 4 , after = last_result ))
1170
+ assert not result2 .errors
1171
+ assert len (result2 .data ["allReporters" ]["edges" ]) == 2
1172
+ assert not result2 .data ["allReporters" ]["pageInfo" ]["hasNextPage" ]
1173
+ gql_reporters = result .data ["allReporters" ]["edges" ] + result2 .data ["allReporters" ]["edges" ]
1174
+
1175
+ assert {
1176
+ to_global_id ("ReporterType" , reporter .id )
1177
+ for reporter in db_reporters
1178
+ } == {
1179
+ gql_reporter ["node" ]["id" ]
1180
+ for gql_reporter in gql_reporters
1181
+ }
1182
+
1166
1183
1167
1184
def test_should_preserve_prefetch_related (django_assert_num_queries ):
1168
1185
class ReporterType (DjangoObjectType ):
0 commit comments