Skip to content

Commit

Permalink
Fix newline at end of generated operation
Browse files Browse the repository at this point in the history
The use of the `\(section:)` interpolation method for `DeferredFragmentsMetadataTemplate` was causing the new line at the end of the generated operation files to be deleted. This corrects that.
  • Loading branch information
AnthonyMDev committed Aug 1, 2024
1 parent eb5aaf7 commit 79e4ca0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class DeferredFragmentsMetadataTemplateTests: XCTestCase {
)
}

private func renderSubject() -> String {
subject.render().description
private func renderSubject() -> String? {
subject.render()?.description
}

// MARK: - Deferred Inline Fragments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,7 @@ class OperationDefinitionTemplateTests: XCTestCase {
expect(actual).to(equalLineByLine(
"""
}
""",
atLine: 73,
ignoringExtraLines: false
Expand Down Expand Up @@ -1120,6 +1121,7 @@ class OperationDefinitionTemplateTests: XCTestCase {
expect(actual).to(equalLineByLine(
"""
}
""",
atLine: 37,
ignoringExtraLines: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ struct DeferredFragmentsMetadataTemplate {
/// Renders metadata definitions for the deferred fragments of an Operation.
///
/// - Returns: The `TemplateString` for the deferred fragments metadata definitions.
func render() -> TemplateString {
func render() -> TemplateString? {
let deferredFragmentPathTypeInfo = DeferredFragmentsPathTypeInfo(
from: operation.rootField.selectionSet.selections
)
guard !deferredFragmentPathTypeInfo.isEmpty else { return "" }
guard !deferredFragmentPathTypeInfo.isEmpty else { return nil }

return """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ struct OperationDefinitionTemplate: OperationTemplateRenderer {
).renderBody())
}
}
\(section: DeferredFragmentsMetadataTemplate(
\(DeferredFragmentsMetadataTemplate(
operation: operation,
config: config,
renderAccessControl: { accessControlModifier(for: .parent) }()
).render())
""")
}

Expand Down

0 comments on commit 79e4ca0

Please sign in to comment.