File tree Expand file tree Collapse file tree 1 file changed +44
-2
lines changed
Tests/GraphQLTests/InputTests Expand file tree Collapse file tree 1 file changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -509,7 +509,7 @@ class InputTests : XCTestCase {
509
509
try graphql (
510
510
schema: schema,
511
511
request: """
512
- query echo($field1: String) {
512
+ query echo($field1: String! = " defaultValue1 " ) {
513
513
echo (
514
514
field1: $field1
515
515
) {
@@ -526,6 +526,25 @@ class InputTests : XCTestCase {
526
526
]
527
527
] )
528
528
)
529
+
530
+ // Test variable doesn't get argument default
531
+ XCTAssertTrue (
532
+ try graphql (
533
+ schema: schema,
534
+ request: """
535
+ query echo($field1: String!) {
536
+ echo (
537
+ field1: $field1
538
+ ) {
539
+ field1
540
+ }
541
+ }
542
+ """ ,
543
+ eventLoopGroup: group,
544
+ variableValues: [ : ]
545
+ ) . wait ( )
546
+ . errors. count > 0
547
+ )
529
548
}
530
549
531
550
func testArgsNullDefault( ) throws {
@@ -692,7 +711,7 @@ class InputTests : XCTestCase {
692
711
try graphql (
693
712
schema: schema,
694
713
request: """
695
- query echo($field1: String) {
714
+ query echo($field1: String = " defaultValue1 " ) {
696
715
echo (
697
716
field1: $field1
698
717
) {
@@ -709,6 +728,29 @@ class InputTests : XCTestCase {
709
728
]
710
729
] )
711
730
)
731
+
732
+ // Test that nullable unprovided variables are coerced to null
733
+ XCTAssertEqual (
734
+ try graphql (
735
+ schema: schema,
736
+ request: """
737
+ query echo($field1: String) {
738
+ echo (
739
+ field1: $field1
740
+ ) {
741
+ field1
742
+ }
743
+ }
744
+ """ ,
745
+ eventLoopGroup: group,
746
+ variableValues: [ : ]
747
+ ) . wait ( ) ,
748
+ GraphQLResult ( data: [
749
+ " echo " : [
750
+ " field1 " : . null
751
+ ]
752
+ ] )
753
+ )
712
754
}
713
755
714
756
// Test that input objects parse as expected from non-null literals
You can’t perform that action at this time.
0 commit comments