【问题标题】:GraphQL playground type detail multiline comment?GraphQL 游乐场类型详细多行注释?
【发布时间】:2019-08-30 12:51:41
【问题描述】:

我正在尝试使用 GraphQL 记录我的 API。对于可读性问题,我想将 cmets 保留在多行中,但它似乎不适用于常规的 '\n' 换行符

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

这是我尝试过的

但是它的输出完全相同,而无需在新行中添加行

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

是否可以在新行中排列文本,例如:

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

【问题讨论】:

    标签: graphql graphql-playground


    【解决方案1】:

    块字符串在设计上不允许转义字符,但您可以在字符串中使用新行:

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

    或者您可以使用允许转义字符的常规字符串:

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

    编辑:

    GraphQL Playground 在后台使用this component 来呈现描述,它本身将描述视为降价并使用markdown-it 呈现它。 Markdown 会忽略单个换行符,因此您必须使用两个:

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

    【讨论】:

    • 两者似乎都不适合我...在 graphql 操场上将所有内容打印在一行中
    • 您指的是 Playground 中的 DOCS 选项卡吗?
    • 是的。我正在 schema.graphql 中编写 cmets 并在 Playground > docs 中查看它
    • 完成。不知道那件事。谢谢!
    猜你喜欢
    • 2021-04-03
    • 1970-01-01
    • 2021-05-13
    • 2020-01-08
    • 2019-12-03
    • 2015-11-23
    • 2020-01-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多