我有一个 graphql 模式,其中的一个片段如下所示:
type User {
username: String!
password: String!
}
在graphiql中,有一个描述字段,但它总是说“ self 描述”。如何向模式添加描述?
最佳答案
如果您使用的是 GraphQL.js 0.7.0 或更高版本,您只需在要描述的字段、类型或参数之前直接添加注释即可。例如:
# A type that describes the user
type User {
# The user's username, should be typed in the login field.
username: String!
# The user's password.
password: String!
}
在 0.7.0 版本以下无法在模式语言中添加描述。
更新:从版本 v0.12.3 开始,您应该使用string literals
"""
A type that describes the user. Its description might not
fit within the bounds of 80 width and so you want MULTILINE
"""
type User {
"The user's username, should be typed in the login field."
username: String!
"The user's password."
password: String!
}
关于javascript - 如何向 "GraphQL schema language"中的字段添加说明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39962867/