Skip to content

Commit 0bc77ae

Browse files
committed
Fix bug when deserializing argument default value.
1 parent 5b3fc0a commit 0bc77ae

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Sources/GraphQL/Execution/Values.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import Foundation
2+
13
/**
24
* Prepares an object map of variableValues of the correct type based on the
35
* provided variable definitions and arbitrary input. If the input cannot be
@@ -42,7 +44,14 @@ func getArgumentValues(argDefs: [GraphQLArgumentDefinition], argASTs: [Argument]
4244
)
4345

4446
if value == nil {
45-
value = argDef.defaultValue.map({ .string($0) })
47+
value = try argDef.defaultValue.flatMap { string in
48+
guard let data = string.data(using: .utf8) else {
49+
return nil
50+
}
51+
52+
let object = try JSONSerialization.jsonObject(with: data)
53+
return try map(from: object)
54+
}
4655
}
4756

4857
if let value = value {

0 commit comments

Comments
 (0)