Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/graphql/schema/idl/SchemaPrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ private void printComments(PrintWriter out, Object graphQLType, String prefix) {
List<String> lines = Arrays.asList(descriptionText.split("\n"));
if (options.isDescriptionsAsHashComments()) {
printMultiLineHashDescription(out, prefix, lines);
} else {
} else if (!lines.isEmpty()) {
if (lines.size() > 1) {
printMultiLineDescription(out, prefix, lines);
} else {
Expand Down
22 changes: 22 additions & 0 deletions src/test/groovy/graphql/schema/idl/SchemaPrinterTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,28 @@ type Query {
'''
}

def "arrayIndexOutOfBoundsException should not occur if a field description of only a newline is passed"() {
given:
GraphQLFieldDefinition fieldDefinition = newFieldDefinition()
.name("field")
.description("\n")
.type(GraphQLString)
.build()

def queryType = new MyTestGraphQLObjectType("Query", "test", Arrays.asList(fieldDefinition))
def schema = GraphQLSchema.newSchema().query(queryType).build()

when:
def result = new SchemaPrinter(noDirectivesOption).print(schema)

then:
result == '''"test"
type Query {
field: String
}
'''
}

def "schema will be sorted"() {
def schema = TestUtil.schema("""
type Query {
Expand Down