J.S.C
J.S.C

Reputation: 1543

GraphQL playground type detail multiline comment?

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

Upvotes: 6

Views: 13897

Answers (1)

Daniel Rearden
Daniel Rearden

Reputation: 84807

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
"""

Upvotes: 17

Related Questions