Skip to content

Commit 574cd2d

Browse files
fix: Fixes trailing commas for Swift < v6.1
1 parent 3d78151 commit 574cd2d

3 files changed

Lines changed: 32 additions & 29 deletions

File tree

.github/workflows/test.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ jobs:
1010
uses: graphqlswift/ci/.github/workflows/lint.yaml@main
1111
test:
1212
uses: graphqlswift/ci/.github/workflows/test.yaml@main
13+
with:
14+
include_android: false
1315
test-example:
1416
uses: graphqlswift/ci/.github/workflows/test.yaml@main
1517
with:
1618
package_path: "Examples/HelloWorldServer"
19+
include_android: false

Sources/GraphQLGeneratorCore/Generator/SchemaGenerator.swift

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package struct SchemaGenerator {
1717
/// Build a GraphQL schema with the provided resolvers
1818
public func buildGraphQLSchema<Resolvers: ResolversProtocol>(
1919
resolvers: Resolvers.Type,
20-
decoder: MapDecoder = .init(),
20+
decoder: MapDecoder = .init()
2121
) throws -> GraphQLSchema {
2222
"""
2323

@@ -203,20 +203,20 @@ package struct SchemaGenerator {
203203
var output = """
204204
205205
let \(varName) = try GraphQLEnumType(
206-
name: "\(type.name)",
206+
name: "\(type.name)"
207207
"""
208208

209209
if let description = type.description {
210210
output += """
211-
211+
,
212212
description: \"\"\"
213213
\(description.indent(1, includeFirst: false))
214-
\"\"\",
214+
\"\"\"
215215
"""
216216
}
217217

218218
output += """
219-
219+
,
220220
values: [
221221
"""
222222

@@ -262,15 +262,15 @@ package struct SchemaGenerator {
262262

263263
var output = """
264264
let \(varName) = try GraphQLInputObjectType(
265-
name: "\(type.name)",
265+
name: "\(type.name)"
266266
"""
267267

268268
if let description = type.description {
269269
output += """
270-
270+
,
271271
description: \"\"\"
272272
\(description)
273-
\"\"\",
273+
\"\"\"
274274
"""
275275
}
276276

@@ -297,27 +297,27 @@ package struct SchemaGenerator {
297297
output += try """
298298
299299
"\(fieldName)": InputObjectField(
300-
type: \(graphQLTypeReference(for: field.type)),
300+
type: \(graphQLTypeReference(for: field.type))
301301
"""
302302

303303
if let defaultValue = field.defaultValue {
304304
output += """
305-
306-
defaultValue: \(mapToSwiftCode(defaultValue)),
305+
,
306+
defaultValue: \(mapToSwiftCode(defaultValue))
307307
"""
308308
}
309309

310310
if let description = field.description {
311311
output += """
312-
312+
,
313313
description: \"\"\"
314314
\(description)
315-
\"\"\",
315+
\"\"\"
316316
"""
317317
}
318318
if let deprecationReason = field.deprecationReason {
319319
output += """
320-
320+
,
321321
deprecationReason: \"\"\"
322322
\(deprecationReason)
323323
\"\"\"
@@ -344,12 +344,12 @@ package struct SchemaGenerator {
344344

345345
var output = """
346346
let \(varName) = try GraphQLInterfaceType(
347-
name: "\(type.name)",
347+
name: "\(type.name)"
348348
"""
349349

350350
if let description = type.description {
351351
output += """
352-
352+
,
353353
description: \"\"\"
354354
\(description)
355355
\"\"\",
@@ -425,15 +425,15 @@ package struct SchemaGenerator {
425425

426426
var output = """
427427
let \(varName) = try GraphQLObjectType(
428-
name: "\(type.name)",
428+
name: "\(type.name)"
429429
"""
430430

431431
if let description = type.description {
432432
output += """
433-
433+
,
434434
description: \"\"\"
435435
\(description)
436-
\"\"\",
436+
\"\"\"
437437
"""
438438
}
439439

@@ -605,31 +605,31 @@ package struct SchemaGenerator {
605605
var output = try """
606606
607607
"\(fieldName)": GraphQLField(
608-
type: \(graphQLTypeReference(for: field.type)),
608+
type: \(graphQLTypeReference(for: field.type))
609609
"""
610610

611611
if let description = field.description {
612612
output += """
613-
613+
,
614614
description: \"\"\"
615615
\(description)
616-
\"\"\",
616+
\"\"\"
617617
"""
618618
}
619619

620620
if let deprecationReason = field.deprecationReason {
621621
output += """
622-
622+
,
623623
deprecationReason: \"\"\"
624624
\(deprecationReason)
625-
\"\"\",
625+
\"\"\"
626626
"""
627627
}
628628

629629
// Add arguments if any
630630
if !field.args.isEmpty {
631631
output += """
632-
632+
,
633633
args: [
634634
"""
635635

@@ -664,12 +664,12 @@ package struct SchemaGenerator {
664664

665665
output += """
666666
667-
],
667+
]
668668
"""
669669
}
670670

671671
output += try"""
672-
672+
,
673673
\(generateResolverCallback(
674674
fieldName: fieldName,
675675
field: field,

Tests/GraphQLGeneratorTests/SchemaGeneratorTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ struct SchemaGeneratorTests {
4545
/// Build a GraphQL schema with the provided resolvers
4646
public func buildGraphQLSchema<Resolvers: ResolversProtocol>(
4747
resolvers: Resolvers.Type,
48-
decoder: MapDecoder = .init(),
48+
decoder: MapDecoder = .init()
4949
) throws -> GraphQLSchema {
5050
let bar = try GraphQLObjectType(
5151
name: "Bar",
5252
description: """
5353
bar
54-
""",
54+
"""
5555
)
5656
bar.fields = {
5757
[

0 commit comments

Comments
 (0)