Skip to content

Commit e359053

Browse files
committed
Comments describing each case
1 parent adb00f0 commit e359053

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/test/groovy/graphql/DefaultValuesTest.groovy

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ class DefaultValuesTest extends Specification {
2323
myField2: df]]
2424
).build()
2525

26+
//
27+
// The variable is present in the variables map and its explicitly null
28+
//
29+
// https://spec.graphql.org/October2021/#sec-Coercing-Variable-Values
30+
//
2631
when:
2732
def ei = newExecutionInput('''
2833
query myQuery($deleted: Boolean = false) {
@@ -35,6 +40,11 @@ class DefaultValuesTest extends Specification {
3540
er.errors.isEmpty()
3641
er.data == [myField: "dataFetcherArg=null"]
3742

43+
//
44+
// The variable is present in the variables map and its explicitly a value
45+
//
46+
// https://spec.graphql.org/October2021/#sec-Coercing-Variable-Values
47+
//
3848
when:
3949
ei = newExecutionInput('''
4050
query myQuery($deleted: Boolean = false) {
@@ -47,6 +57,12 @@ class DefaultValuesTest extends Specification {
4757
er.errors.isEmpty()
4858
er.data == [myField: "dataFetcherArg=true"]
4959

60+
//
61+
// The variable is NOT present in the variables map it should use a default
62+
// value from the variable declaration
63+
//
64+
// https://spec.graphql.org/October2021/#sec-Coercing-Variable-Values
65+
//
5066
when:
5167
ei = newExecutionInput('''
5268
query myQuery($deleted: Boolean = false) {
@@ -59,6 +75,11 @@ class DefaultValuesTest extends Specification {
5975
er.errors.isEmpty()
6076
er.data == [myField: "dataFetcherArg=false"]
6177

78+
//
79+
// The variable is NOT present in the variables map and a variable is NOT used
80+
// it should use a default value from the field declaration
81+
//
82+
//
6283
when:
6384
ei = newExecutionInput('''
6485
query myQuery($deleted: Boolean = false) {
@@ -73,6 +94,11 @@ class DefaultValuesTest extends Specification {
7394
er.data == [myField : "dataFetcherArg=true",
7495
myField2: "dataFetcherArg=false"]
7596

97+
//
98+
// If there are no variables on the query operation
99+
// it should use a default value from the field declaration
100+
// or literals provided
101+
//
76102
when:
77103
ei = newExecutionInput('''
78104
query myQuery {

0 commit comments

Comments
 (0)