Skip to content

Offset pagination with "last N before X" should not include the item at offset X #840

Closed
@nilshartmann

Description

@nilshartmann

When executing a query with a ScrollSubrange that contains both last and before the node with the before cursor is returned in the result.

query {
  posts(last:2, before:"T18z") {
    edges {
      cursor  # contains T18z in the result, and not the 2 nodes BEFORE T18z
    }
  }
}
  @QueryMapping
  public Window<Post> posts(ScrollSubrange subrange) {
      ScrollPosition position = subrange.position().orElse(ScrollPosition.offset());
      int count = subrange.count().orElse(5);

      var result = postRepository.findAllBy(position, Limit.of(count), Sort.by("id"));

      return result;
  }

I think the before node should not be included in the result (similar to first X after where after is also not included in the result). The graphql.relay.SimpleListConnection class also do not return the before node.

I tested with Spring Boot 3.2.0-M3 and used the out-of-the-box configuration (no changes to wiring etc.)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions