0

I played with the API and was able to find all repositories I ever contributed to, but I struggle to find my very first commit.

What I tried:

{
  viewer {
    repositoriesContributedTo(first: 100, privacy: PUBLIC, contributionTypes: COMMIT, before: "2013-07-11T00:00:00") {
      totalCount
      nodes {
        nameWithOwner
      }
      pageInfo {
        endCursor
        hasNextPage
      }
    }
  }
}

What I got:

{
  "errors": [
    {
      "type": "INVALID_CURSOR_ARGUMENTS",
      "path": [
        "viewer",
        "repositoriesContributedTo",
        "nodes"
      ],
      "locations": [
        {
          "line": 5,
          "column": 7
        }
      ],
      "message": "`2013-07-11T00:00:00` does not appear to be a valid cursor."
    },
    {
      "type": "INVALID_CURSOR_ARGUMENTS",
      "path": [
        "viewer",
        "repositoriesContributedTo",
        "pageInfo"
      ],
      "locations": [
        {
          "line": 8,
          "column": 7
        }
      ],
      "message": "`2013-07-11T00:00:00` does not appear to be a valid cursor."
    }
  ]
}

Link to GitHub's GraphQL explorer: https://developer.github.com/v4/explorer/

Jürgen Gmach
  • 5,366
  • 3
  • 20
  • 37

1 Answers1

0

To find the first commit , you can order by the CREATED_AT in the ascending order:

{
  viewer {
    repositoriesContributedTo(
      first: 100
      orderBy: {
        field : CREATED_AT
        direction : ASC
      }
      privacy: PUBLIC
      contributionTypes: COMMIT) {
      totalCount
      nodes {
        nameWithOwner
      }
      pageInfo {
        startCursor
        endCursor
        hasNextPage
      }
    }
  }
}

P.S. The before field in the input argument is supposed to be assigned with the cursor value which is get from the startCursor or endCursor in the pageInfo result but not a date string.

Ken Chan
  • 84,777
  • 26
  • 143
  • 172
  • Hi Ken, thank you for the answer and especially for the explanation. Have you tried your code for yourself? I think the result cannot be correct. I do search for my single first commit I ever did to Open Source / public repository on GitHub. With your code I get back a list of over 60 repositories with a sort order I cannot understand. The first one is where I contributed in March 2019, the last in June 2018. But I do contribute at least weekly to open source, and by scrolling down GitHubs front page I found a commit back in 2015, which does not appear in your result list. – Jürgen Gmach Nov 22 '19 at 07:51
  • Is it possible, that the "CREATED_AT" does not refer to the commits, but to the repositories? – Jürgen Gmach Nov 22 '19 at 07:51