Skip to content

Commit 6cb3731

Browse files
committed
Fix pagination indicators when using list slices
According to the spec, if hasNextPage and hasPreviousPage should be set regardless of the pagination direction if they can be efficiently computed.
1 parent 2a39f05 commit 6cb3731

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Diff for: graphql_relay/connection/arrayconnection.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,14 @@ def connection_from_list_slice(list_slice, args=None, connection_type=None,
9090

9191
first_edge_cursor = edges[0].cursor if edges else None
9292
last_edge_cursor = edges[-1].cursor if edges else None
93-
lower_bound = after_offset + 1 if after else 0
94-
upper_bound = before_offset if before else list_length
9593

9694
return connection_type(
9795
edges=edges,
9896
page_info=pageinfo_type(
9997
start_cursor=first_edge_cursor,
10098
end_cursor=last_edge_cursor,
101-
has_previous_page=isinstance(last, int) and start_offset > lower_bound,
102-
has_next_page=isinstance(first, int) and end_offset < upper_bound
99+
has_previous_page=start_offset > 0,
100+
has_next_page=end_offset < list_length
103101
)
104102
)
105103

0 commit comments

Comments
 (0)