@@ -17,6 +17,7 @@ class ExecutionResultImplTest extends Specification {
1717 def errors = er. getErrors()
1818 def specMap = er. toSpecification()
1919 then :
20+ er. isDataPresent()
2021 actual == " hello world"
2122
2223 errors. size() == 0
@@ -33,6 +34,7 @@ class ExecutionResultImplTest extends Specification {
3334 def errors = er. getErrors()
3435 def specMap = er. toSpecification()
3536 then :
37+ er. isDataPresent()
3638 actual == " hello world"
3739
3840 errors. size() == 1
@@ -43,6 +45,9 @@ class ExecutionResultImplTest extends Specification {
4345 specMap[" errors" ] == EXPECTED_SPEC_ERRORS
4446 }
4547
48+ // According to https://graphql.github.io/graphql-spec/June2018/#sec-Data,
49+ // there's a disctinction between `null` data, and no data at all.
50+ // See test below
4651 def " errors and no data" () {
4752 given :
4853 def er = new ExecutionResultImpl (KNOWN_ERRORS )
@@ -51,6 +56,7 @@ class ExecutionResultImplTest extends Specification {
5156 def errors = er. getErrors()
5257 def specMap = er. toSpecification()
5358 then :
59+ ! er. isDataPresent()
5460 actual == null
5561
5662 errors. size() == 1
@@ -60,6 +66,28 @@ class ExecutionResultImplTest extends Specification {
6066 specMap[" errors" ] == EXPECTED_SPEC_ERRORS
6167 }
6268
69+ // According to https://graphql.github.io/graphql-spec/June2018/#sec-Data,
70+ // there's a disctinction between `null` data, and no data at all.
71+ // See test above
72+ def "errors and (present ) null data" () {
73+ given:
74+ def er = new ExecutionResultImpl(null, KNOWN_ERRORS)
75+ when:
76+ def actual = er.getData()
77+ def errors = er.getErrors()
78+ def specMap = er.toSpecification()
79+ then:
80+ er.isDataPresent()
81+ actual == null
82+
83+ errors.size() == 1
84+ errors == KNOWN_ERRORS
85+
86+ specMap.size() == 2
87+ specMap[" errors" ] == EXPECTED_SPEC_ERRORS
88+ specMap[" data" ] == null
89+ }
90+
6391 def " can have extensions" () {
6492
6593 given:
0 commit comments