admin管理员组文章数量:1356815
We have a github project with custom field such as Sprint and story points. Below is the sample query that I am trying using Octokit.GraphQL.Net
var query = new Query()
.Repository("my-repo", "my-")
.Issue(1234)
.Select(issue => new
{
issue.Number,
issue.Title,
issue.Url,
ProjectItems = issue.ProjectItems(10, null, null, null, null).Nodes
.Select(p => new
{
p.Id,
p.Type,
Sprint = p.FieldValueByName("Sprint") // <<------ **** Failing here *****
}).ToList()
}).Compile();
var result = await connection.Run(query);
Error reported is
Newtonsoft.Json.JsonSerializationException: 'Unable to find a constructor to use for type Octokit.GraphQL.Model.ProjectV2ItemFieldValue. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute. Path 'data.repository.issue.projectItems.nodes[0].sprint', line 1, position 255.'
Trying to get something like this /blog/graphql-intro/#aliases which has custom project fields.
Query I ran through github client from powershell
gh api graphql -F owner='my-' -F name='my-repo' -f query='
query($name: String!, $owner: String!) {
repository(owner: $owner, name: $name) {
issue(number: 1234) {
number
title
url
projectItems(first: 50) {
nodes {
id
type
project {
title
}
sprint: fieldValueByName(name: "Sprint") {
... on ProjectV2ItemFieldIterationValue {
title
}
}
storypoints: fieldValueByName(name: "Story Points") {
... on ProjectV2ItemFieldNumberValue
{
number
}
}
}
}
}
}
}'
Output I get is as below and I am looking something similar from Ocktokit.graphql
{
"data": {
"repository": {
"issue": {
"number": 1234,
"title": "Dummy Issue",
"url": ";,
"projectItems": {
"nodes": [
{
"id": "PVTI_lADOCiN9Zs4AkRCMzgVWLXE",
"type": "ISSUE",
"project": {
"title": "my-project"
},
"sprint": {
"title": "Sprint 6"
},
"storypoints": {
"number": 3.0
}
}
]
}
}
}
}
}
本文标签: netHow to retrieve Project custom properties or field values in OctokitGraphQLNetStack Overflow
版权声明:本文标题:.net - How to retrieve Project custom properties or field values in Octokit.GraphQL.Net - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743993557a2572586.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论