Skip to content

Commit 6011fd3

Browse files
authored
Fixed nullablity in DefaultEdge (graphql-java#658)
1 parent 465271b commit 6011fd3

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/main/java/graphql/relay/DefaultEdge.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
public class DefaultEdge<T> implements Edge<T> {
99

1010
public DefaultEdge(T node, ConnectionCursor cursor) {
11-
this.node = assertNotNull(node, "node cannot be null");
1211
this.cursor = assertNotNull(cursor, "cursor cannot be null");
12+
this.node = node;
1313
}
1414

1515
/**

src/test/groovy/graphql/relay/SimpleListConnectionTest.groovy

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,17 @@ class SimpleListConnectionTest extends Specification {
6767
notThrown(InvalidCursorException)
6868

6969
}
70+
71+
def "can accept a list with nulls"() {
72+
given:
73+
def dataWithNull = ["a", null, "b"]
74+
def env = newDataFetchingEnvironment().build()
75+
76+
when:
77+
def connection = new SimpleListConnection(dataWithNull).get(env)
78+
79+
then:
80+
connection.getEdges().size() == 3
81+
connection.getEdges().get(1).getNode() == null
82+
}
7083
}

0 commit comments

Comments
 (0)