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/language/AstPrinter.java
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,11 @@ class IntrospectionResultToSchemaTest extends Specification {

then:
result == """type QueryType implements Query {
hero(
\"\"\"
hero(\"\"\"
comment about episode
on two lines
\"\"\"
episode: Episode
foo: String = \"bar\"): Character @deprecated(reason: "killed off character")
episode: Episode, foo: String = \"bar\"): Character @deprecated(reason: "killed off character")
}"""

}
Expand Down Expand Up @@ -212,9 +210,13 @@ class IntrospectionResultToSchemaTest extends Specification {
then:
result == """"A character in the Star Wars Trilogy"
interface Character {
"The id of the character."
id: String!
"The name of the character."
name: String
"The friends of the character, or an empty list if they have none."
friends: [Character]
"Which movies they appear in."
appearsIn: [Episode]
}"""

Expand Down Expand Up @@ -407,22 +409,23 @@ input CharacterInput {
}

type QueryType {
hero(
"If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode."
hero("If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode."
episode: Episode): Character
human(
"id of the human"
human("id of the human"
id: String!): Human
droid(
"id of the droid"
droid("id of the droid"
id: String!): Droid
}

"A character in the Star Wars Trilogy"
interface Character {
"The id of the character."
id: String!
"The name of the character."
name: String
"The friends of the character, or an empty list if they have none."
friends: [Character]
"Which movies they appear in."
appearsIn: [Episode]
}

Expand All @@ -438,19 +441,29 @@ enum Episode {

"A humanoid creature in the Star Wars universe."
type Human implements Character {
"The id of the human."
id: String!
"The name of the human."
name: String
"The friends of the human, or an empty list if they have none."
friends: [Character]
"Which movies they appear in."
appearsIn: [Episode]
"The home planet of the human, or null if unknown."
homePlanet: String
}

"A mechanical creature in the Star Wars universe."
type Droid implements Character {
"The id of the droid."
id: String!
"The name of the droid."
name: String
"The friends of the droid, or an empty list if they have none."
friends: [Character]
"Which movies they appear in."
appearsIn: [Episode]
"The primary function of the droid."
primaryFunction: String
}
"""
Expand Down Expand Up @@ -975,4 +988,4 @@ scalar EmployeeRef
scalar EmployeeRef
'''
}
}
}
20 changes: 20 additions & 0 deletions src/test/groovy/graphql/language/AstPrinterTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,26 @@ type Query {

}

def "print field descriptions"() {
def query = '''type Query {
"description"
field(
"description"
a: String): String
}
'''
def document = parse(query)
String output = printAst(document)
expect:
output == '''type Query {
"description"
field(
"description"
a: String): 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