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 {
509509 try graphql (
510510 schema: schema,
511511 request: """
512- query echo($field1: String) {
512+ query echo($field1: String! = " defaultValue1 " ) {
513513 echo (
514514 field1: $field1
515515 ) {
@@ -526,6 +526,25 @@ class InputTests : XCTestCase {
526526 ]
527527 ] )
528528 )
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+ )
529548 }
530549
531550 func testArgsNullDefault( ) throws {
@@ -692,7 +711,7 @@ class InputTests : XCTestCase {
692711 try graphql (
693712 schema: schema,
694713 request: """
695- query echo($field1: String) {
714+ query echo($field1: String = " defaultValue1 " ) {
696715 echo (
697716 field1: $field1
698717 ) {
@@ -709,6 +728,29 @@ class InputTests : XCTestCase {
709728 ]
710729 ] )
711730 )
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+ )
712754 }
713755
714756 // Test that input objects parse as expected from non-null literals
You can’t perform that action at this time.
0 commit comments