File tree 2 files changed +16
-7
lines changed 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -7,18 +7,25 @@ import OrderedCollections
7
7
* parsed to match the variable definitions, a GraphQLError will be thrown.
8
8
*/
9
9
func 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 {
12
13
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 (
15
23
schema: schema,
16
24
definitionAST: defAST,
17
- input: inputs [ varName ] ?? . null
25
+ input: input
18
26
)
19
-
20
- return valuesCopy
21
27
}
28
+ return vars
22
29
}
23
30
24
31
Original file line number Diff line number Diff line change @@ -709,6 +709,8 @@ extension Map : Equatable {}
709
709
710
710
public func == ( lhs: Map , rhs: Map ) -> Bool {
711
711
switch ( lhs, rhs) {
712
+ case ( . undefined, . undefined) :
713
+ return true
712
714
case ( . null, . null) :
713
715
return true
714
716
case let ( . bool( l) , . bool( r) ) where l == r:
You can’t perform that action at this time.
0 commit comments