如何使用graphql(v4 API)访问github存储库内容?

如果我使用github v3 api通过以下查询访问公共存储库的目录内容:

curl https://api.github.com/repos/w3c/webappsec/contents/

graphql中的等效项是什么?

例如,我可以通过将以下内容发送到https://api.github.com/graphql

来获得存储库的描述。
query TestQuery{
    repository(owner:"w3c" name:"webappsec"){
      description
    }
  }

但是如何获取存储库目录的内容?

hanpangzi2234 回答:如何使用graphql(v4 API)访问github存储库内容?

您可以使用object(expression: "branch_name:")并列出树条目:

{
  repository(owner: "w3c",name: "webappsec") {
    object(expression: "master:") {
      ... on Tree {
        entries {
          name
          type
          mode
        }
      }
    }
  }
}

Try it in the explorer

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

大家都在问