GraphQL playground type detail multiline comment?
Asked Answered
C

1

6

I am trying to document my APIs using GraphQL. For readability issues, I want to leave comments in multi-line but it doesn't seem to work with regular '\n' newline symbol

"""
  Return:\n true : DB save successful\n false : DB save unsuccessful
"""

This is what i tried

However it outputs exactly the same without putting lines in the new line

Return:\n true : DB save successful\n false : DB save unsuccessful

Is it possible to arrange texts in new line like:

Return:
 true : DB save successful
 false : DB save unsuccessful
Chita answered 29/8, 2019 at 7:8 Comment(0)
M
17

Block strings don't allow escaping characters by design, but you can just utilize new lines inside the string:

"""
Return:
true : DB save successful
false : DB save unsuccessful
"""

Or you can utilize a regular string, which allows escaped characters:

"Return:\n true : DB save successful\n false : DB save unsuccessful"

EDIT:

GraphQL Playground uses this component under the hood to render the descriptions, which itself treats the description as markdown and renders it using markdown-it. Markdown ignores single line breaks, so you would have to use two:

"""
Return:

true : DB save successful

false : DB save unsuccessful
"""
Mcripley answered 29/8, 2019 at 11:8 Comment(4)
Both don't seem to work for me... prints everything in one line in graphql playgroundChita
Are you referring to the DOCS tab in Playground?Mcripley
yes. I'm writing comments in schema.graphql and viewing it in playground > docsChita
Done. didn't know about that. Thanks!Chita

© 2022 - 2024 — McMap. All rights reserved.