Fix IndexOutOfBoundsException for empty Window
Closes gh-775
This commit is contained in:
@@ -217,6 +217,10 @@ public final class ConnectionFieldTypeVisitor extends GraphQLTypeVisitorStub {
|
||||
}
|
||||
|
||||
Collection<T> nodes = this.adapter.getContent(container);
|
||||
if (nodes.isEmpty()) {
|
||||
return EMPTY_CONNECTION;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
List<Edge<T>> edges = new ArrayList<>(nodes.size());
|
||||
for (T node : nodes) {
|
||||
|
||||
@@ -66,6 +66,23 @@ public class SchemaMappingPaginationTests {
|
||||
"}}}");
|
||||
}
|
||||
|
||||
@Test // gh-775
|
||||
void zeroResults() {
|
||||
|
||||
String document = BookSource.booksConnectionQuery("first:0, after:\"O_3\"");
|
||||
Mono<ExecutionGraphQlResponse> response = graphQlService().execute(document);
|
||||
|
||||
ResponseHelper.forResponse(response).assertData("""
|
||||
{"books":{\
|
||||
"edges":[],\
|
||||
"pageInfo":{\
|
||||
"startCursor":null,\
|
||||
"endCursor":null,\
|
||||
"hasPreviousPage":false,\
|
||||
"hasNextPage":false}}}"""
|
||||
);
|
||||
}
|
||||
|
||||
private TestExecutionGraphQlService graphQlService() {
|
||||
|
||||
ScrollPositionCursorStrategy cursorStrategy = new ScrollPositionCursorStrategy();
|
||||
|
||||
Reference in New Issue
Block a user