Getting commit's parents


#1

Hello,

in the REST api, when you got a commit object, it had a parents field, I’m really lost as to how to get to that info with the GraphQL. I use the following query to get commits from a repo,

{
  repository(owner: "golang", name: "go") {
    defaultBranchRef {
      target {
        ... on Commit {
          history(first: 10) {
            pageInfo {
              hasNextPage
              endCursor
            }
            edges {
              node {
                oid
                messageHeadline
              }
            }
          }
        }
      }
    }
  }
}

any advice on how to access each commit’s parent? Thank you


#2

This seems to work:

{
  repository(owner: "golang", name: "go") {
    defaultBranchRef {
      target {
        ... on Commit {
          history(first: 10) {
            pageInfo {
              hasNextPage
              endCursor
            }
            edges {
              node {
                oid
                messageHeadline
                parents(first:1) {
                  edges {
                    node {
                      oid
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}