0

I am trying to run the following query on Githubs GraphQL api:

{
  user(login: "davekaj") {
    id
    repositories(first: 10, orderBy: {field: NAME, direction: ASC}) {
      nodes {
        ref(qualifiedName: "master") {
          target {
            ... on Commit {
              history(first: 15, author: "WHAT DO I PUT HERE") {
                totalCount
                nodes {
                  additions
                  author {
                    name
                    user {
                      id
                    }
                  }
                  committedDate
                  deletions
                }
              }
            }
          }
        }
      }
    }
  }
}

It wants me to filter on a CommitAuthor for history(author: ). I tried passing my username, or my unique user ID, but it doesn't work. I am essentially passing it a string, but it wants the type CommitAuthor. How do I pass a CommitAuthor value?

It isn't clear to me, and I searched through the docs and the schema and I couldn't find anything.

Please help!

dave kajpust
  • 141
  • 3

1 Answers1

1

Ah, so the answer is actually very simple once I looked at the graphql documentation (rather than just the github documentation). CommitAuthor is an input type, which is described here https://graphql.org/graphql-js/mutations-and-input-types/.

The result is you pass an object of CommitAuthor. In this case I just have to pass the id, which looks like this: author: {id: "MDQ6VXNlcjIyNDE3Mzgy"}

See the completed code below.

{
  user(login: "davekaj") {
    id
    repositories(first: 10, orderBy: {field: NAME, direction: ASC}) {
      nodes {
        ref(qualifiedName: "master") {
          target {
            ... on Commit {
              history(first: 15, author: {id: "MDQ6VXNlcjIyNDE3Mzgy"}) {
                totalCount
                nodes {
                  additions
                  author {
                    name
                    user {
                      id
                    }
                  }
                  committedDate
                  deletions
                }
              }
            }
          }
        }
      }
    }
  }
}
dave kajpust
  • 141
  • 3