lib/graphql/pagination/relation_connection.rb in graphql-1.13.5 vs lib/graphql/pagination/relation_connection.rb in graphql-1.13.6

- old
+ new

@@ -45,11 +45,11 @@ end def cursor_for(item) load_nodes # index in nodes + existing offset + 1 (because it's offset, not index) - offset = nodes.index(item) + 1 + (@paged_nodes_offset || 0) + (relation_offset(items) || 0) + offset = nodes.index(item) + 1 + (@paged_nodes_offset || 0) - (relation_offset(items) || 0) encode(offset.to_s) end private @@ -114,13 +114,13 @@ def calculate_sliced_nodes_parameters if defined?(@sliced_nodes_limit) return else + next_offset = relation_offset(items) || 0 if after_offset - previous_offset = relation_offset(items) || 0 - relation_offset = previous_offset + after_offset + next_offset += after_offset end if before_offset && after_offset if after_offset < before_offset # Get the number of items between the two cursors @@ -134,10 +134,10 @@ # Use limit to cut off the tail of the relation relation_limit = before_offset - 1 end @sliced_nodes_limit = relation_limit - @sliced_nodes_offset = relation_offset || 0 + @sliced_nodes_offset = next_offset end end # Apply `before` and `after` to the underlying `items`, # returning a new relation.