GraphQL | Can we implement search by programming language in GitHub GraphQL API using Directives?
我正在尝试GraphQL,我想创建一个GraphQL脚本进行高级搜索。我一直想弄清楚如何搜索包含特定语言的存储库。例如,我只想搜索用Kotlin编写的存储库。这就是我的查询内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | query AdvancedSearch($query: String!, $type: SearchType!, $numOfResults: Int!, $nextPageCursor: String) { search(type: $type, query: $query, first: $numOfResults, after: $nextPageCursor) { pageInfo { hasNextPage endCursor } repositoryCount nodes { ... on Repository { name nameWithOwner description languages(first: 100) { nodes { name } } } } } |
} ??
我正在考虑在语言中使用@skip指令,例如
1 | languages(first:100) @skip(if:$filterLanguage !="Kotlin") |
我不想在搜索查询中传递" language:kotlin ",我想使用指令来做到这一点。这样可能吗?
摘自规范:http://spec.graphql.org/June2018/#sec--skip
The
@skip directive may be provided for fields, fragment spreads, and inline fragments, and allows for conditional exclusion during execution as described by the if argument.
换句话说,
更重要的是,包含或省略特定字段不会影响任何父字段的执行方式。如果您打算修改