Open SimpleSamples opened 5 years ago
Okay I got it.
Using the following for RepositoryModel (I added TotalCount):
class RepositoryModel
{
public string Name { get; set; }
public string Description { get; set; }
public List<IssueModel> Issues { get; set; }
public int TotalCount;
}
The following query works:
Octokit.GraphQL.Core.IQueryableValue<RepositoryModel> query = new Query()
.Repository("octokit.graphql.net", "octokit")
.Select(r => new RepositoryModel
{
Name = r.Name,
Description = r.Description,
TotalCount = r.Issues(100, null, null, null, null, null, null).TotalCount,
Issues = r.Issues(100, null, null, null, null, null, null).Nodes.Select(i => new IssueModel
{
Number = i.Number,
Title = i.Title,
}).ToList(),
});
I am constructing an IssueConnection twice and if there is a way to use just one IssueConnection for both then I hope someone else can improve that.
The important part of this version (compared to what is in the original post) is that IssueConnection has a "Nodes" that is the list of issues.
👋 Hey Friends, this issue has been automatically marked as stale
because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned
label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!
The sample at the bottom of Writing Queries is wrong. The syntax for creating a named object is different from anonymous objects. The following is a complete sample that works except I don't know how to get the issues.
A minor issue is that the Repository method arguments are reversed.
The important part that is incorrect is:
The problem with the issues is that Repository.Issues is an IssueConnection, right? I get the impression that the definition of issues has been (appropriately) made more complicated after the article was written.
Also, I avoid using var but fans of var can change that code if they feel it is necessary. I don't think it will make a difference here.