File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed
Tests/GraphQLTests/LanguageTests Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,63 @@ class SchemaParserTests: XCTestCase {
111111 XCTAssert ( result == expected)
112112 }
113113
114+ func testParsesTypeWithDescriptionString( ) throws {
115+ let doc = try parse ( source: """
116+ " Description "
117+ type Hello {
118+ world: String
119+ }
120+ """ )
121+
122+ let type = try XCTUnwrap ( doc. definitions [ 0 ] as? ObjectTypeDefinition )
123+
124+ XCTAssertEqual (
125+ type. description? . value,
126+ " Description "
127+ )
128+ }
129+
130+ func testParsesTypeWithDescriptionMultiLineString( ) throws {
131+ let doc = try parse ( source: #"""
132+ """
133+ Description
134+ """
135+ # Even with comments between them
136+ type Hello {
137+ world: String
138+ }
139+ """# )
140+
141+ let type = try XCTUnwrap ( doc. definitions [ 0 ] as? ObjectTypeDefinition )
142+
143+ XCTAssertEqual (
144+ type. description? . value,
145+ " Description "
146+ )
147+ }
148+
149+ func testParsesSchemaWithDescriptionMultiLineString( ) throws {
150+ let doc = try parse ( source: """
151+ " Description "
152+ schema {
153+ query: Foo
154+ }
155+ """ )
156+
157+ let type = try XCTUnwrap ( doc. definitions [ 0 ] as? SchemaDefinition )
158+
159+ XCTAssertEqual (
160+ type. description? . value,
161+ " Description "
162+ )
163+ }
164+
165+ func testDescriptionFollowedBySomethingOtherThanTypeSystemDefinitionThrows( ) throws {
166+ XCTAssertThrowsError (
167+ try parse ( source: #""Description" 1"# )
168+ )
169+ }
170+
114171 func testSchemeExtension( ) throws {
115172 // Based on Apollo Federation example schema: https://github.com/apollographql/apollo-federation-subgraph-compatibility/blob/main/COMPATIBILITY.md#products-schema-to-be-implemented-by-library-maintainers
116173 let source =
You can’t perform that action at this time.
0 commit comments