1

I'm trying to convert this query into a struct:

{
  repository(owner: "google", name: "gson") {
    name
    refs(first: 100, refPrefix: "refs/heads/") {
      edges {
        node {
          name
          target {
            ... on Commit {
              id
              history(first: 2) {
                totalCount
                edges {
                  node {
                    ... on Commit {
                      committer {
                        date
                        email
                        name
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

I got this from github api: How to efficiently find the number of commits for a repository?

I tested it on the Github explorer just to be safe and its working as it should. What I'm trying to do is to get the "TotalCount" of commits per contributor to a specific Repository. I'm not really sure how I'm supposed to do it exactly. I already got this:

type repositoryInfo struct {
    Repository struct {
        Refs struct {
            TotalCount githubv4.Int //number of branches
            Nodes []ref
            PageInfo pageInfo
        }`graphql:"refs(refPrefix:$prefix,first:$refFirst,after:$refAfter,orderBy:$orderBy)"`
    } `graphql:"repository(owner:$login,name:$repositoryName)"`
}

type ref struct {
    Name githubv4.String
    Prefix githubv4.String

    Target struct {
        AbbreviatedOid githubv4.String
        ID githubv4.GitObjectID
        //History struct {
        //  TotalCount githubv4.Int
        //}`graphql:"history(first:0)"`
    }`graphql:"... on Commit"`
}

But I get this error message:

Fragment on Commit can't be spread inside Ref

However I can't seem to find any useful documentation. Can anybody tell me what I'm doing wrong please?

Nox
  • 11
  • 2

0 Answers0