File tree Expand file tree Collapse file tree 5 files changed +19606
-6913
lines changed
Sources/SwiftGraphQLCodegen/Generator
Tests/SwiftGraphQLCodegenTests/Generator
thesocialnetwork/ios/TheSocialNetwork/Shared/GraphQL Expand file tree Collapse file tree 5 files changed +19606
-6913
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,11 @@ extension Field {
9292 // NOTE: It's possible that a string contains double-quoted characters in deprecation reason.
9393 // http://spec.graphql.org/October2021/#sec-Language.Directives
9494 let message = deprecationReason? . replacingOccurrences ( of: " \" " , with: " \\ \" " ) ?? " "
95- return " @available(*, deprecated, message: \" \( message) \" ) "
95+ if message. contains ( " \n " ) {
96+ return " @available(*, deprecated, message: \" \" \" \n \( message) \n \" \" \" ) "
97+ } else {
98+ return " @available(*, deprecated, message: \" \( message) \" ) "
99+ }
96100 }
97101 return " "
98102 }
Original file line number Diff line number Diff line change @@ -78,6 +78,51 @@ final class FieldTests: XCTestCase {
7878 """ )
7979 }
8080
81+ func testMultilineDeprecationReason( ) throws {
82+ let field = Field (
83+ name: " id " ,
84+ description: " Deprecation \n Multiline. " ,
85+ args: [ ] ,
86+ type: . named( . scalar( " ID " ) ) ,
87+ isDeprecated: true ,
88+ deprecationReason: """
89+ Use ID instead.
90+ See: <link> for more detail.
91+ """
92+ )
93+
94+ let generated = try field. getDynamicSelection (
95+ parent: " TestType " ,
96+ context: Context . from ( scalars: [ " ID " : " String " ] )
97+ ) . format ( )
98+
99+ let expected = """
100+ /// Deprecation
101+ /// Multiline.
102+ @available(*, deprecated, message: \" \" \"
103+ Use ID instead.
104+ See: <link> for more detail.
105+ \" \" \" )
106+ public func id() throws -> String? {
107+ let field = GraphQLField.leaf(
108+ field: " id " ,
109+ parent: " TestType " ,
110+ arguments: []
111+ )
112+ self.__select(field)
113+
114+ switch self.__state {
115+ case .decoding:
116+ return try self.__decode(field: field.alias!) { try String?(from: $0) }
117+ case .selecting:
118+ return nil
119+ }
120+ }
121+ """
122+
123+ generated. assertInlineSnapshot ( matching: expected)
124+ }
125+
81126 // MARK: - Scalar
82127
83128 func testScalarField( ) throws {
You can’t perform that action at this time.
0 commit comments