How to structure Github APIv4 Golang Query for specific release

How to structure Github APIv4 Golang Query for specific release


0

Using https://github.com/shurcooL/githubv4 and I’m really struggling to pull back a specific Release for a gh repo.

The below code block keeps returning nothing when there is a v3 release:

var releaseQ struct {
  Repository struct {
    Release struct {
        Author githubv4.String
    } `graphql:"release(tagName:$tagName)"`
  } `graphql:"repository(owner:$repositoryOwner,name:$repositoryName)"`
}
variables = map[string]interface{}{
    "repositoryOwner": githubv4.String("jacobtomlinson"),
    "repositoryName":  githubv4.String("gha-find-replace"),
    "tagName":         githubv4.String("v3"),
}
err = client.Query(context.Background(), &releaseQ, variables)
if err != nil {
    fmt.Println("Query returned nothing")
}
fmt.Println("author:", releaseQ.Repository.Release.Author)

I’ve successfully got the following two code blocks working for repo description and issue reactions:

var repoDescriptionQ struct {
  Repository struct {
    Description string
  } `graphql:"repository(owner: "jacobtomlinson", name: "gha-find-replace")"`
}

this successfully returned repo description ^

variables := map[string]interface{}{
  "repositoryOwner": githubv4.String("jacobtomlinson"),
  "repositoryName":  githubv4.String("gha-find-replace"),
  "issueNumber":     githubv4.Int(55),
  "reactionContent": githubv4.ReactionContentThumbsDown,
}
var reactionQ struct {
Repository struct {
    Issue struct {
        ID        githubv4.ID
        Reactions struct {
            ViewerHasReacted githubv4.Boolean
        } `graphql:"reactions(content:$reactionContent)"`
    } `graphql:"issue(number:$issueNumber)"`
} `graphql:"repository(owner:$repositoryOwner,name:$repositoryName)"`
}

this successfully got a reaction ^


Load 7 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *