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
10 changes: 9 additions & 1 deletion src/language/__tests__/schema-kitchen-sink.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ of the `Foo` type.
"""
type Foo implements Bar & Baz {
one: Type
two(argument: InputType!): Type
"""
This is a description of the `two` field.
"""
two(
"""
This is a description of the `argument` argument.
"""
argument: InputType!
): Type
three(argument: InputType, other: String): Int
four(argument: String = "string"): String
five(argument: [String] = ["string", "string"]): String
Expand Down
10 changes: 9 additions & 1 deletion src/language/__tests__/schema-printer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ describe('Printer: SDL document', () => {
"""
type Foo implements Bar & Baz {
one: Type
two(argument: InputType!): Type
"""
This is a description of the \`two\` field.
"""
two(
"""
This is a description of the \`argument\` argument.
"""
argument: InputType!
): Type
three(argument: InputType, other: String): Int
four(argument: String = "string"): String
five(argument: [String] = ["string", "string"]): String
Expand Down
8 changes: 6 additions & 2 deletions src/language/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ const printDocASTReducer = {
FieldDefinition: addDescription(
({ name, arguments: args, type, directives }) =>
name +
wrap('(', join(args, ', '), ')') +
(args.every(arg => arg.indexOf('\n') === -1)
? wrap('(', join(args, ', '), ')')
: wrap('(\n', indent(join(args, '\n')), '\n)')) +
': ' +
type +
wrap(' ', join(directives, ' ')),
Expand Down Expand Up @@ -212,7 +214,9 @@ const printDocASTReducer = {
({ name, arguments: args, locations }) =>
'directive @' +
name +
wrap('(', join(args, ', '), ')') +
(args.every(arg => arg.indexOf('\n') === -1)
? wrap('(', join(args, ', '), ')')
: wrap('(\n', indent(join(args, '\n')), '\n)')) +
' on ' +
join(locations, ' | '),
),
Expand Down