什么是GraphQL查询来确定组织中是否存在GitHub软件包?

如何查询GitHub软件包以确定软件包是否已存在?我想防止CI / CD尝试发布Maven软件包(如果该软件包已经存在)。

我正在尝试如下查询:

curl -X POST -H "Authorization: bearer <some token>" -H "accept: application/vnd.github.packages-preview+json" -d <my query> https://api.github.com/graphql 

<my query>如下:

query {
  organization(login: "myorg") {
    registryPackagesForQuery(packageType: MAVEN,first: 100) {
      edges {
        node {
            name
            id
        }
      } 
    }
  }
}

我要退回我的包裹:

{
  "data": {
    "organization": {
      "registryPackagesForQuery": {
        "edges": [
          {
            "node": {
              "name": "com.example.myorg","id": "<some id>"
            }
          }
        ]
      }
    }
  }
}

但是,query有一个String参数(类型为registryPackagesForQuery),但是我不知道该查询格式应该如何显示。任何试图添加值的尝试似乎都不会返回任何数据。

查询的正确格式是什么?如果我要检查软件包的特定版本,此查询有何变化?

基本的查询文档在这里:https://developer.github.com/v4/query/

组织:https://developer.github.com/v4/object/organization/

RegistryPackageConnection:https://developer.github.com/v4/object/registrypackageconnection

RegistryPackage:https://developer.github.com/v4/object/registrypackage/

yaoji2011 回答:什么是GraphQL查询来确定组织中是否存在GitHub软件包?

这可能是题外话,但是使用Maven插件会更简单吗?像https://github.com/chonton/exists-maven-plugin一样?

本文链接:https://www.f2er.com/3094297.html

大家都在问