使用GraphQL Java时,如何编写架构定义文件的注释,并将其反映到GraphiQL或GraphQL Playground中

根据学习初次使用GraphQL Web服务的新一代API,当在模式定义文件中为每个模式添加注释时,需要用三个双引号将其括起来,如下所示。

"""本"""
type Book {

    """ID"""
    id: ID

    """名前"""
    name: String

    """ページ数"""
    pageCount: Int

    """著者"""
    author: Author![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/23101/6f44c6e0-4691-8ca9-a029-0d5ef55f6d7e.png)

}

我在Java + Spring Boot中轻量级地编写GraphQL时注意到,使用上述写法时,GraphiQL和GraphQL Playground将不会反映,并且会显示为”No Description”。

因此,我們通過在開頭加上#符號來解決了這個問題。

# 本
type Book {

    # ID
    id: ID

    # 名前
    name: String

    # ページ数
    pageCount: Int

    # 著者
    author: Author
}
image.png
广告
将在 10 秒后关闭
bannerAds