-
Notifications
You must be signed in to change notification settings - Fork 0
Replace Octokit Release API with GraphQL queries using ReleaseNode #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
93cb236
4ae2fb2
ba5a8bb
ce91b03
a1820c1
e2a22ca
aaafacb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -166,7 +166,7 @@ | |
| { | ||
| // Fetch all data from GitHub in parallel | ||
| var commitsTask = GetAllCommitsAsync(graphqlClient, owner, repo, branch); | ||
| var releasesTask = client.Repository.Release.GetAll(owner, repo); | ||
| var releasesTask = GetAllReleasesAsync(graphqlClient, owner, repo); | ||
| var tagsTask = client.Repository.GetAllTags(owner, repo); | ||
| var pullRequestsTask = client.PullRequest.GetAllForRepository(owner, repo, new PullRequestRequest { State = ItemStateFilter.All }); | ||
| var issuesTask = client.Issue.GetAllForRepository(owner, repo, new RepositoryIssueRequest { State = ItemStateFilter.All }); | ||
|
|
@@ -572,6 +572,33 @@ | |
| return commitShas.Select(sha => new Commit(sha)).ToList(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets all releases for a repository using GraphQL pagination. | ||
| /// </summary> | ||
| /// <param name="graphqlClient">GitHub GraphQL client.</param> | ||
| /// <param name="owner">Repository owner.</param> | ||
| /// <param name="repo">Repository name.</param> | ||
| /// <returns>List of all releases.</returns> | ||
| private static async Task<IReadOnlyList<Release>> GetAllReleasesAsync( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems there are two data types introduced - ReleaseNode and Release, and the code goes from ReleaseNode to string, to release. Don't add extra types and extra conversions.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in e2a22ca. Removed the custom Release type and the extra conversions. Now |
||
| GitHubGraphQLClient graphqlClient, | ||
| string owner, | ||
| string repo) | ||
| { | ||
| // Fetch all release tag names for the repository using GraphQL | ||
| var releaseTagNames = await graphqlClient.GetReleasesAsync(owner, repo); | ||
|
|
||
| // Convert tag names to Release objects using JSON deserialization | ||
| // This creates minimal Release objects with only TagName populated | ||
| return releaseTagNames.Select(tagName => | ||
|
Malcolmnixon marked this conversation as resolved.
Outdated
|
||
| { | ||
| // Use JsonConvert with a proper object to avoid JSON injection | ||
| var releaseData = new { tag_name = tagName }; | ||
| var json = Newtonsoft.Json.JsonConvert.SerializeObject(releaseData); | ||
| var release = Newtonsoft.Json.JsonConvert.DeserializeObject<Release>(json); | ||
| return release ?? throw new InvalidOperationException($"Failed to create Release object for tag {tagName}"); | ||
| }).ToList(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets commits in the range from fromHash (exclusive) to toHash (inclusive). | ||
| /// </summary> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not have this return a list of ReleaseNode records?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in e2a22ca. Changed
GetReleasesAsyncto returnList<ReleaseNode>directly, eliminating the intermediate string conversion.