Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AstPrinter to print field descriptions #2808

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/graphql/language/AstPrinter.java
Expand Up @@ -163,7 +163,7 @@ private NodePrinter<FieldDefinition> fieldDefinition() {
final String argSep = compactMode ? "," : ", ";
return (out, node) -> {
String args;
if (hasDescription(node.getInputValueDefinitions()) && !compactMode) {
if (hasDescription(Collections.singletonList(node)) && !compactMode) {
out.append(description(node));
args = join(node.getInputValueDefinitions(), "\n");
out.append(node.getName())
Expand Down
16 changes: 16 additions & 0 deletions src/test/groovy/graphql/language/AstPrinterTest.groovy
Expand Up @@ -472,6 +472,22 @@ type Query {

}

def "print field descriptions"() {
def query = '''type Query {
"comment"
field: String
}
'''
def document = parse(query)
String output = printAst(document)
expect:
output == '''type Query {
"comment"
field: String
}
'''
}

def "print empty description"() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems there is a test failing IntrospectionResultToSchemaTest > test starwars introspection result FAILED

def query = '''
""
Expand Down