File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
test/groovy/graphql/relay Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,10 @@ public Connection<T> get(DataFetchingEnvironment environment) {
4646
4747 List <Edge <T >> edges = buildEdges ();
4848
49+ if (edges .size () == 0 ) {
50+ return emptyConnection ();
51+ }
52+
4953 ConnectionCursor firstPresliceCursor = edges .get (0 ).getCursor ();
5054 ConnectionCursor lastPresliceCursor = edges .get (edges .size () - 1 ).getCursor ();
5155
Original file line number Diff line number Diff line change @@ -81,4 +81,16 @@ class SimpleListConnectionTest extends Specification {
8181 connection. getEdges(). size() == 3
8282 connection. getEdges(). get(1 ). getNode() == null
8383 }
84+
85+ def " can accept an empty list" () {
86+ given :
87+ def empty = []
88+ def env = newDataFetchingEnvironment(). executionContext(Mock (ExecutionContext )). build()
89+
90+ when :
91+ def connection = new SimpleListConnection (empty). get(env)
92+
93+ then :
94+ connection. getEdges(). size() == 0
95+ }
8496}
You can’t perform that action at this time.
0 commit comments