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
}
}
]
}
}
}
}
}