shurcooL / githubv4

Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://docs.github.com/en/graphql).
MIT License
1.11k stars 89 forks source link

Unable to get query commit in repository. #51

Closed mou closed 4 years ago

mou commented 4 years ago

Trying to perform this query

query {
  repository(owner: "octocat", name: "Hello-world") {
    object(oid:"e212ffe458a5f1df7647ee461aff22c7b3a52580") {
      ... on Commit {
        pushedDate
      }
    }
  }
}

For this i use next go code:

    var q struct {
        Repository struct {
            Object struct {
                Commit struct {
                    pushedDate github.DateTime
                } `graphql:"... on Commit"`
            } `graphql:"object(oid: $sha)"`
        } `graphql:"repository(owner: \"octocat\", name: $name)"`
    }

    variables := map[string]interface{}{
        "name":  github.String("Hello-World"),
        "sha": github.GitObjectID("e212ffe458a5f1df7647ee461aff22c7b3a52580"),
    }

    err := client.Query(ctx, &q, variables)

In the end i got error: struct field for "pushedDate" doesn't exist in any of 2 places to unmarshal

mou commented 4 years ago

Sorry. Golang newbie messed up with private declarations