使用https://github.com/shurcooL/githubv4,我真的很难为gh repo拉回一个特定的版本。
下面的代码块在有v3版本时保持不返回任何内容:
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)
字符串
我已经成功地让以下两个代码块用于repo描述和问题React:
var repoDescriptionQ struct {
Repository struct {
Description string
} `graphql:"repository(owner: \"jacobtomlinson\", name: \"gha-find-replace\")"`
}
型
此成功返回的存储库描述^
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)"`
}
型
这成功地得到了React^
1条答案
按热度按时间35g0bw711#
首先,Author字段不是字符串,而是“User”类型。将请求的字段更改为Description,这是一个字符串,它正在拉回发布信息。如果您确实想要Author,则需要定义User:
字符串