Skip to content

Commit 9bc9cae

Browse files
chore: Formatting and dead code removal
1 parent e2b39fb commit 9bc9cae

4 files changed

Lines changed: 3 additions & 45 deletions

File tree

Sources/GraphQLGeneratorCore/Parser/SchemaParser.swift

Lines changed: 0 additions & 7 deletions
This file was deleted.

Sources/GraphQLGeneratorCore/Utilities/swiftTypeName.swift

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func swiftTypeReference(for type: GraphQLType, includeNamespace: Bool, nameGener
3939
return "(any \(baseName))?"
4040
}
4141
if let scalarType = namedType as? GraphQLScalarType {
42-
let swiftScalar = mapScalarType(scalarType, includeNamespace: includeNamespace, nameGenerator: nameGenerator)
42+
let swiftScalar = mapScalarType(scalarType, nameGenerator: nameGenerator)
4343
return "\(swiftScalar)?"
4444
}
4545
return "\(baseName)?"
@@ -81,7 +81,7 @@ func swiftTypeDeclaration(for type: GraphQLType, includeNamespace: Bool, nameGen
8181
/// - graphQLType: The GraphQL Type to generate a reference to
8282
/// - includeNamespace: Whether to include the `GraphQLGenerated` type namespace in the result
8383
/// - nameGenerator: The name generator
84-
func mapScalarType(_ type: GraphQLScalarType, includeNamespace: Bool, nameGenerator: SafeNameGenerator) -> String {
84+
func mapScalarType(_ type: GraphQLScalarType, nameGenerator: SafeNameGenerator) -> String {
8585
switch type.name {
8686
case "ID": return "String"
8787
case "String": return "String"
@@ -94,37 +94,3 @@ func mapScalarType(_ type: GraphQLScalarType, includeNamespace: Bool, nameGenera
9494
return "GraphQLScalars.\(baseName)"
9595
}
9696
}
97-
98-
/// Converts a Map value to valid Swift code representation
99-
func mapToSwiftCode(_ map: Map) -> String {
100-
switch map {
101-
case .undefined:
102-
return ".undefined"
103-
case .null:
104-
return ".null"
105-
case let .bool(value):
106-
return ".bool(\(value))"
107-
case let .number(value):
108-
return ".number(Number(\(value)))"
109-
case let .string(value):
110-
// Escape special characters for Swift string literal
111-
let escaped = value
112-
.replacingOccurrences(of: "\\", with: "\\\\")
113-
.replacingOccurrences(of: "\"", with: "\\\"")
114-
.replacingOccurrences(of: "\n", with: "\\n")
115-
.replacingOccurrences(of: "\r", with: "\\r")
116-
.replacingOccurrences(of: "\t", with: "\\t")
117-
return ".string(\"\(escaped)\")"
118-
case let .array(values):
119-
let elements = values.map { mapToSwiftCode($0) }.joined(separator: ", ")
120-
return ".array([\(elements)])"
121-
case let .dictionary(dict):
122-
let pairs = dict.map { key, value in
123-
let escapedKey = key
124-
.replacingOccurrences(of: "\\", with: "\\\\")
125-
.replacingOccurrences(of: "\"", with: "\\\"")
126-
return "\"\(escapedKey)\": \(mapToSwiftCode(value))"
127-
}.joined(separator: ", ")
128-
return ".dictionary([\(pairs)])"
129-
}
130-
}

Tests/GraphQLGeneratorCoreTests/SchemaGeneratorTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ struct SchemaGeneratorTests {
245245
#expect(result == expected)
246246
}
247247

248-
249248
// MARK: - Resolver Callback Tests
250249

251250
@Test func generateResolverCallbackForParent() throws {

Tests/GraphQLGeneratorCoreTests/TypeGeneratorTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ struct TypeGeneratorTests {
217217
args: [
218218
"baz": .init(
219219
type: GraphQLNonNull(scalar)
220-
)
220+
),
221221
]
222222
),
223223
],

0 commit comments

Comments
 (0)