shurcooL / githubv4

Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://docs.github.com/en/graphql).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to get query commit in repository.

mou opened this issue · comments

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

Sorry. Golang newbie messed up with private declarations