3

I am using Github's GraphQL (v4) API to make some calls. I am trying to get commits information about a repository, but I am having issues with defining the since attribute of the history connection of the Commit object.

I am getting the following error back:

{
    "data": null,
    "errors": [
        {
            "message": "Argument 'since' on Field 'history' has an invalid value. Expected type 'GitTimestamp'.",
            "locations": [
                {
                    "line": 38,
                    "column": 9
                }
            ]
        }
    ]
}

And this is the extracted part of my GraphQL which is causing the error:

query {
    search(query:"is:public", type:REPOSITORY, first:10){       
        edges{
            node{
                ... on Repository{
                    ref(qualifiedName: "master"){
                        target{                         
                            ... on Commit{                              
                                history(first: 10, since:"2017-07-15"){                                 
                                    totalCount
                                    pageInfo{
                                        startCursor
                                        endCursor
                                    }
                                    edges{
                                        node{
                                            ... on Commit{
                                                committedDate
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

According to the documentation, the GitTimestamp scalar is an ISO-8601 encoded date string. So, what is the problem with my string "2017-07-15"? I have also tried the following strings, which none worked.

  • 2017/01/01
  • 2017.01.01
  • 2017-01-01 01:01
  • 2017-01-01T01:01
  • 2017-01-01 01:01Z
  • 2017-01-01T01:01Z
Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159
FTM
  • 1,887
  • 17
  • 34
  • 1
    you need to set hour:minute:second : `2017-07-15T01:01:00` – Bertrand Martel Jan 16 '18 at 12:39
  • Damn seconds... It worked! You can tag your comment as the answer to the problem Bertrand! – FTM Jan 16 '18 at 14:54
  • 1
    Learned so much in the last few days about GraphQL that I summarized my endeavor with a post on Medium: https://medium.com/@fabiomolinar/using-githubs-graphql-to-retrieve-a-list-of-repositories-their-commits-and-some-other-stuff-ccbbb4e96d78 – FTM Jan 16 '18 at 20:27

1 Answers1

6

You have to specify a date in the format YYYY-MM-DDTHH:MM:SSZ. The following will work :

  • 2017-01-01T01:01:00
  • 2017-01-01T01:01:00Z

Try it in the explorer

{
  search(query: "is:public", type: REPOSITORY, first: 10) {
    edges {
      node {
        ... on Repository {
          ref(qualifiedName: "master") {
            target {
              ... on Commit {
                history(first: 10, since: "2017-01-01T01:01:00") {
                  totalCount
                  pageInfo {
                    startCursor
                    endCursor
                  }
                  edges {
                    node {
                      ... on Commit {
                        committedDate
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159