Skip to content

Commit 61a2dab

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 17ce2ef commit 61a2dab

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

graphql_relay/connection/arrayconnection.py

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

9494
first_edge_cursor = edges[0].cursor if edges else None
9595
last_edge_cursor = edges[-1].cursor if edges else None
96-
lower_bound = after_offset + 1 if after else 0
97-
upper_bound = before_offset if before else list_length
9896

9997
return connection_type(
10098
edges=edges,
10199
page_info=pageinfo_type(
102100
start_cursor=first_edge_cursor,
103101
end_cursor=last_edge_cursor,
104-
has_previous_page=isinstance(last, int) and start_offset > lower_bound,
105-
has_next_page=isinstance(first, int) and end_offset < upper_bound
102+
has_previous_page=start_offset > 0,
103+
has_next_page=end_offset < list_length
106104
)
107105
)
108106

0 commit comments

Comments
 (0)