diff --git a/src/language-graphql/printer-graphql.js b/src/language-graphql/printer-graphql.js index 154cb37f..210757d8 100644 --- a/src/language-graphql/printer-graphql.js +++ b/src/language-graphql/printer-graphql.js @@ -374,6 +374,8 @@ function genericPrint(path, options, print) { case "EnumValueDefinition": { return concat([ + path.call(print, "description"), + n.description ? hardline : "", path.call(print, "name"), printDirectives(path, print, n) ]); @@ -381,6 +383,8 @@ function genericPrint(path, options, print) { case "InputValueDefinition": { return concat([ + path.call(print, "description"), + n.description ? (n.description.block ? hardline : line) : "", path.call(print, "name"), ": ", path.call(print, "type"), diff --git a/tests/graphql_string/__snapshots__/jsfmt.spec.js.snap b/tests/graphql_string/__snapshots__/jsfmt.spec.js.snap index 5636e278..601e1611 100644 --- a/tests/graphql_string/__snapshots__/jsfmt.spec.js.snap +++ b/tests/graphql_string/__snapshots__/jsfmt.spec.js.snap @@ -29,6 +29,26 @@ of the \`one\` field. """ one: Type } + +type Foo { +q("docs" field: String): Type +q("A long string of description of the field parameter to make this break" field: String): Type +q("""docs""" field: String): Type +} + +enum Enum { +""" +Description of \`one\` +""" +one +} + +input Input { +""" +Description of \`one\` +""" +one: string +} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ query X($a: Int) @relay(meta: "{\\"lowPri\\": true}") { a @@ -65,4 +85,32 @@ type Foo { one: Type } +type Foo { + q("docs" field: String): Type + q( + "A long string of description of the field parameter to make this break" + field: String + ): Type + q( + """ + docs + """ + field: String + ): Type +} + +enum Enum { + """ + Description of \`one\` + """ + one +} + +input Input { + """ + Description of \`one\` + """ + one: string +} + `; diff --git a/tests/graphql_string/string.graphql b/tests/graphql_string/string.graphql index 3a174cfb..dea48a4a 100644 --- a/tests/graphql_string/string.graphql +++ b/tests/graphql_string/string.graphql @@ -26,3 +26,23 @@ of the `one` field. """ one: Type } + +type Foo { +q("docs" field: String): Type +q("A long string of description of the field parameter to make this break" field: String): Type +q("""docs""" field: String): Type +} + +enum Enum { +""" +Description of `one` +""" +one +} + +input Input { +""" +Description of `one` +""" +one: string +}