File tree Expand file tree Collapse file tree 1 file changed +8
-16
lines changed Expand file tree Collapse file tree 1 file changed +8
-16
lines changed Original file line number Diff line number Diff line change @@ -23,26 +23,18 @@ def cursor_from_node(item)
23
23
end
24
24
end
25
25
26
- def record_exists? ( record )
27
- if ( defined? ( ActiveRecord ::Relation ) && record . is_a? ( ActiveRecord ::Relation ) )
28
- record . exists?
29
- else
30
- !record . empty?
31
- end
32
- end
33
-
34
26
def has_next_page
35
27
if first
36
- if after
37
- paged_nodes . length >= first && record_exists? ( nodes . offset ( first + offset_from_cursor ( after ) ) )
38
- else
39
- paged_nodes . length >= first && record_exists? ( nodes . offset ( first ) )
28
+ if defined? ( ActiveRecord ::Relation ) && nodes . is_a? ( ActiveRecord ::Relation )
29
+ initial_offset = after ? offset_from_cursor ( after ) : 0
30
+ return paged_nodes . length >= first && nodes . offset ( first + initial_offset ) . exists?
40
31
end
41
- elsif GraphQL :: Relay :: ConnectionType . bidirectional_pagination && last
42
- sliced_nodes_count >= last
43
- else
44
- false
32
+ return paged_nodes . length >= first && sliced_nodes_count > first
33
+ end
34
+ if GraphQL :: Relay :: ConnectionType . bidirectional_pagination && last
35
+ return sliced_nodes_count >= last
45
36
end
37
+ false
46
38
end
47
39
48
40
def has_previous_page
You can’t perform that action at this time.
0 commit comments