Skip to content

Commit fd8c7bf

Browse files
committed
Get rid double conversion Map => String => Map
1 parent 130e6f1 commit fd8c7bf

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

Sources/GraphQL/Execution/Values.swift

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,11 @@ func getArgumentValues(argDefs: [GraphQLArgumentDefinition], argASTs: [Argument]
3737
let name = argDef.name
3838
let valueAST = argASTMap[name]?.value
3939

40-
var value = try valueFromAST(
40+
let value = try valueFromAST(
4141
valueAST: valueAST,
4242
type: argDef.type,
4343
variables: variableValues
44-
)
45-
46-
if value == nil {
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, options: .allowFragments)
53-
return try map(from: object)
54-
}
55-
}
44+
) ?? argDef.defaultValue
5645

5746
if let value = value {
5847
result[name] = value

Sources/GraphQL/Type/Definition.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ public struct GraphQLArgument {
667667
public struct GraphQLArgumentDefinition {
668668
public let name: String
669669
public let type: GraphQLInputType
670-
public let defaultValue: String?
670+
public let defaultValue: Map?
671671
public let description: String?
672672

673673
init(
@@ -678,7 +678,7 @@ public struct GraphQLArgumentDefinition {
678678
) {
679679
self.name = name
680680
self.type = type
681-
self.defaultValue = defaultValue?.description
681+
self.defaultValue = defaultValue
682682
self.description = description
683683
}
684684
}

Sources/GraphQL/Type/Introspection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ let __InputValue = try! GraphQLObjectType(
360360
return nil
361361
}
362362

363-
return .string(defaultValue)
363+
return .string(defaultValue.description)
364364
}
365365
)
366366
]

0 commit comments

Comments
 (0)