File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -7,18 +7,25 @@ import OrderedCollections
77 * parsed to match the variable definitions, a GraphQLError will be thrown.
88 */
99func getVariableValues( schema: GraphQLSchema , definitionASTs: [ VariableDefinition ] , inputs: [ String : Map ] ) throws -> [ String : Map ] {
10- return try definitionASTs. reduce ( [ : ] ) { values, defAST in
11- var valuesCopy = values
10+
11+ var vars = [ String: Map] ( )
12+ for defAST in definitionASTs {
1213 let varName = defAST. variable. name. value
13-
14- valuesCopy [ varName] = try getVariableValue (
14+
15+ let input : Map
16+ if let nonNilInput = inputs [ varName] {
17+ input = nonNilInput
18+ } else {
19+ // If variable is not in inputs it is undefined
20+ input = . undefined
21+ }
22+ vars [ varName] = try getVariableValue (
1523 schema: schema,
1624 definitionAST: defAST,
17- input: inputs [ varName ] ?? . null
25+ input: input
1826 )
19-
20- return valuesCopy
2127 }
28+ return vars
2229}
2330
2431
Original file line number Diff line number Diff line change @@ -709,6 +709,8 @@ extension Map : Equatable {}
709709
710710public func == ( lhs: Map , rhs: Map ) -> Bool {
711711 switch ( lhs, rhs) {
712+ case ( . undefined, . undefined) :
713+ return true
712714 case ( . null, . null) :
713715 return true
714716 case let ( . bool( l) , . bool( r) ) where l == r:
You can’t perform that action at this time.
0 commit comments