Используйте GitHub GraphQL для извлечения всех открытых вех и всех проблем (открытых и закрытых) для вехи - PullRequest
0 голосов
/ 14 февраля 2020

Я понимаю, что API GitHub на основе GraphQL v4 гораздо более эффективен, чем API v3.

Я бы хотел использовать API GraphQL для извлечения для данного репо:

  1. Все открытые этапы.
  2. Для каждого этапа, его названия, описания, всех его проблем (открытых и закрытых)
  3. Для каждого выпуска, его названия, описания, статуса и все сообщения.

Есть ли прямой способ сделать это?

1 Ответ

2 голосов
/ 14 февраля 2020

Да. Это легко сделать. Запрос выглядит следующим образом:

{
  repository(owner: "gatsbyjs", name: "gatsby") {
    description
    url
    milestones(states: [OPEN],first:2) {
      nodes{
        title
        description
        url
        issues(states:[OPEN,CLOSED], first:2){
          nodes{
            title
            state
            url
            comments(first:2){
              nodes{
                url
                body
                createdAt
              }
              pageInfo{
                hasNextPage
                endCursor
              }
            }
          }
          pageInfo{
             endCursor
             hasNextPage
          }
        }
      }
      pageInfo{
        endCursor
        hasNextPage
      }
    }
  }
}

Примечание:

  • Для хранилища с URL-адресом https://github.com/gatsbyjs/gatsby его владельцем является gatsbyjs, а его именем является gatsby

  • Go в его API Explorer , чтобы попытаться настроить запрос. Нажмите Ctrl + Пробел автоматически предложит доступные поля, которые можно извлечь.

  • Выполните разбиение на страницы самостоятельно до l oop через все записи, отрегулировав начальный курсор и количество записей для возвращается в first, after.

Это дает вам следующее:

{
  "data": {
    "repository": {
      "description": "Build blazing fast, modern apps and websites with React",
      "url": "https://github.com/gatsbyjs/gatsby",
      "milestones": {
        "nodes": [
          {
            "title": "Next Major",
            "description": "Issues that will require a breaking change, and which would constitute being done in the next major version of Gatsby.",
            "url": "https://github.com/gatsbyjs/gatsby/milestone/5",
            "issues": {
              "nodes": [
                {
                  "title": "Make accessibility warnings errors",
                  "state": "OPEN",
                  "url": "https://github.com/gatsbyjs/gatsby/issues/19945",
                  "comments": {
                    "nodes": [
                      {
                        "url": "https://github.com/gatsbyjs/gatsby/issues/19945#issuecomment-568891716",
                        "body": "Hiya!\n\nThis issue has gone quiet. Spooky quiet. ?\n\nWe get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.\nIf we missed this issue or if you want to keep it open, please reply here. You can also add the label \"not stale\" to keep this issue open!\nAs a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out [gatsby.dev/contribute](https://www.gatsbyjs.org/contributing/how-to-contribute/) for more information about opening PRs, triaging issues, and contributing!\n\nThanks for being a part of the Gatsby community! ??",
                        "createdAt": "2019-12-25T12:02:26Z"
                      },
                      {
                        "url": "https://github.com/gatsbyjs/gatsby/issues/19945#issuecomment-570779866",
                        "body": "Hey again!\n\nIt’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.\nPlease keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m `HUMAN_EMOTION_SORRY`. Please feel free to reopen this issue or create a new one if you need anything else.\nAs a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out [gatsby.dev/contribute](https://www.gatsbyjs.org/contributing/how-to-contribute/) for more information about opening PRs, triaging issues, and contributing!\n\nThanks again for being part of the Gatsby community! ??",
                        "createdAt": "2020-01-04T12:02:28Z"
                      }
                    ],
                    "pageInfo": {
                      "hasNextPage": false,
                      "endCursor": "Y3Vyc29yOnYyOpHOIgVo2g=="
                    }
                  }
                },
                {
                  "title": "Configurable output folder",
                  "state": "OPEN",
                  "url": "https://github.com/gatsbyjs/gatsby/issues/1878",
                  "comments": {
                    "nodes": [
                      {
                        "url": "https://github.com/gatsbyjs/gatsby/issues/1878#issuecomment-324062470",
                        "body": "Do you have a specific use case in mind? This has been discussed before but no one has come up with a concrete use case that justified adding a new option.\r\n\r\nEvery option we add to Gatsby makes the project more complex which has all sorts of long-term costs so unless something is really valuable, I'd rather people handle this sort of thing themselves e.g. just copy the files to the output directory you want or create a symlink. This could easily be turned into a plugin that people could install, etc.",
                        "createdAt": "2017-08-22T15:27:41Z"
                      },
                      {
                        "url": "https://github.com/gatsbyjs/gatsby/issues/1878#issuecomment-324074853",
                        "body": "Yes, I have a use-case. I am going to use Gatsby for a documentation part as a part of complex project. All static files (Gatsby output, plus some others) should be placed into one folder `build`, that will be deployed somehow later. In other words, the Gatsby output is only one subfolder in my setup.\r\n\r\nSo far I have worked this around in `postbuild` step, but it looks hacky:\r\n\r\n```\r\n\"build\": \"gatsby build\",\r\n\"postbuild\": \"mv public build/gatsby-subsite\"\r\n```\r\nAdding configurable output folder will reduce this complexity and will help me not to move files around one more time.",
                        "createdAt": "2017-08-22T16:08:21Z"
                      }
                    ],
                    "pageInfo": {
                      "hasNextPage": true,
                      "endCursor": "Y3Vyc29yOnYyOpHOE1D9ZQ=="
                    }
                  }
                }
              ],
              "pageInfo": {
                "endCursor": "Y3Vyc29yOnYyOpLPgAAAAAAAArvODwULXA==",
                "hasNextPage": true
              }
            }
          }
        ],
        "pageInfo": {
          "endCursor": "Y3Vyc29yOnYyOpHOAEEbsw==",
          "hasNextPage": false
        }
      }
    }
  }
}
...