sangria-graphql/sangria

Schema rendering problems with Windows line separators

ArminWiebigke opened this issue · 1 comments

If source files are using Windows line separators, then the schema renderer seems to include the \r\n line breaks inside multi-line comments from the source files. The renderer logic seems to expect \n line breaks though, and because of that creates lines that contain only spaces (from the indentation).

Example of unexpected output, using + instead of space as indentation for readability:

type SomeType {
++"""
++Some value.
++
++The line above should be empty.
++"""
++value: String!
}

It seems like the cause of the problem is just this single statement:

val lines = escapeBlockString(node.value).split("\n").iterator.map { line =>
if (line.isEmpty) line // do not output lines with only whitespaces inside
else ind + line
}

Changing .split("\n").iterator to .linesIterator should probably fix the issue.

Thanks for the issue. ❤️
Do you have to try to propose a PR for this?
I guess that we could add a test case in https://github.com/sangria-graphql/sangria/blob/main/modules/core/src/test/scala/sangria/renderer/QueryRendererSpec.scala to cover this.