Github GraphQL API:如何找出哪些字段是可搜索的?
Github GraphQL API: How can I find out which fields are searchable?
当我运行查询时:
{
"query": "{user(login: \"furknyavuz\") {repositories(first: 50, isPrivate: false) {nodes {name url}}}}"
}
我收到以下错误:
{
"data": null,
"errors": [
{
"message": "Field 'repositories' doesn't accept argument 'isPrivate'",
"locations": [
{
"line": 1,
"column": 51
}
]
}
]
}
我可以看到 isPivate 是 Repository 对象的字段,但我无法使用它进行搜索。
我不希望搜索对象的所有字段,但关键问题是,如何查看哪些字段可搜索或可索引?
自动完成:
导航至 Github 的 GraphQL API Explorer。这是一个 GraphiQL 界面,可让您实时编写查询和 运行。 GraphiQL 的一项巧妙功能是包含自动完成功能。当您为字段输入参数时,只需按 Alt+Space 或 Shift+Space 并且会弹出一个可能的参数列表。这也适用于字段。
文档:
您还可以通过点击界面右上角的 Docs
link 查看架构的文档。这将显示所有可能字段的列表,包括它们采用的参数。还有一个架构参考页 here.
GraphQL:
最后,您实际上可以自己询问 GraphQL 端点。例如,运行此查询将列出架构的所有类型以及每个类型使用的参数:
{
__schema {
types {
name
inputFields {
name
description
type {
name
}
defaultValue
}
}
}
}
isPrivate
是 Repository
对象的字段,但 repositories
inside User object is of type RepositoryConnection and repositories
连接项具有以下 argument/type:
- 隶属关系 [RepositoryAffiliation]
- 在字符串
之后
- 在字符串之前
- 第一个 Int
- isFork 布尔值
- isLocked 布尔值
- 最后一个 Int
- orderBy RepositoryOrder
- 隐私 RepositoryPrivacy
RepositoryPrivacy
是一个具有两个值的枚举:PUBLIC 和 PRIVATE。
以下请求将 return 私人回购:
{
user(login: "furknyavuz") {
repositories(first: 50, privacy:PRIVATE) {
nodes {
name
url
}
}
}
}
请注意,在 the explorer 中,如果您键入 CTRL+space,您将获得包含以下类型的架构列表:
此外,CTRL+space 在“:”之后再次为您提供枚举值:
当我运行查询时:
{
"query": "{user(login: \"furknyavuz\") {repositories(first: 50, isPrivate: false) {nodes {name url}}}}"
}
我收到以下错误:
{
"data": null,
"errors": [
{
"message": "Field 'repositories' doesn't accept argument 'isPrivate'",
"locations": [
{
"line": 1,
"column": 51
}
]
}
]
}
我可以看到 isPivate 是 Repository 对象的字段,但我无法使用它进行搜索。
我不希望搜索对象的所有字段,但关键问题是,如何查看哪些字段可搜索或可索引?
自动完成:
导航至 Github 的 GraphQL API Explorer。这是一个 GraphiQL 界面,可让您实时编写查询和 运行。 GraphiQL 的一项巧妙功能是包含自动完成功能。当您为字段输入参数时,只需按 Alt+Space 或 Shift+Space 并且会弹出一个可能的参数列表。这也适用于字段。
文档:
您还可以通过点击界面右上角的 Docs
link 查看架构的文档。这将显示所有可能字段的列表,包括它们采用的参数。还有一个架构参考页 here.
GraphQL:
最后,您实际上可以自己询问 GraphQL 端点。例如,运行此查询将列出架构的所有类型以及每个类型使用的参数:
{
__schema {
types {
name
inputFields {
name
description
type {
name
}
defaultValue
}
}
}
}
isPrivate
是 Repository
对象的字段,但 repositories
inside User object is of type RepositoryConnection and repositories
连接项具有以下 argument/type:
- 隶属关系 [RepositoryAffiliation]
- 在字符串 之后
- 在字符串之前
- 第一个 Int
- isFork 布尔值
- isLocked 布尔值
- 最后一个 Int
- orderBy RepositoryOrder
- 隐私 RepositoryPrivacy
RepositoryPrivacy
是一个具有两个值的枚举:PUBLIC 和 PRIVATE。
以下请求将 return 私人回购:
{
user(login: "furknyavuz") {
repositories(first: 50, privacy:PRIVATE) {
nodes {
name
url
}
}
}
}
请注意,在 the explorer 中,如果您键入 CTRL+space,您将获得包含以下类型的架构列表:
此外,CTRL+space 在“:”之后再次为您提供枚举值: