Skip to content

Commit 5d863a5

Browse files
committed
fix: issues, x3
1 parent 5fd664c commit 5d863a5

2 files changed

Lines changed: 26 additions & 12 deletions

File tree

src/Action/Issue.psm1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ function Test-Hash {
8181
body
8282
baseRefName
8383
}
84+
}
8485
}
8586
rateLimit {
8687
remaining

src/Github.psm1

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@ Join-Path $PSScriptRoot 'Helpers.psm1' | Import-Module
33
function Invoke-GithubGraphQL {
44
<#
55
.SYNOPSIS
6-
Invoke authenticated GitHub GraphQL API request with parallel query support and fallback.
6+
Invoke authenticated GitHub GraphQL API request with retry logic.
77
.PARAMETER Query
88
GraphQL query string.
99
.PARAMETER Variables
1010
Hashtable of variables for the GraphQL query.
11-
.PARAMETER UseFallback
12-
If set, falls back to REST API on GraphQL failure.
1311
.PARAMETER MaxRetries
1412
Maximum number of retry attempts on rate limit. Default is 3.
1513
.EXAMPLE
1614
Invoke-GithubGraphQL -Query 'query { viewer { login } }'
1715
#>
1816
param(
19-
[Parameter(Mandatory, ValueFromPipeline)]
17+
[Parameter(Mandatory)]
2018
[String] $Query,
2119
[Hashtable] $Variables,
2220
[Int] $MaxRetries = 3
@@ -102,23 +100,39 @@ function Invoke-GithubGraphQLParallel {
102100
Execute multiple GraphQL queries in parallel to avoid rate limits.
103101
.PARAMETER Queries
104102
Array of hashtables containing Query and Variables.
105-
.PARAMETER UseFallback
106-
If set, falls back to REST API on GraphQL failure.
107103
.EXAMPLE
108104
$queries = @(
109105
@{ Query = 'query($owner:String!, $name:String!) { repository(owner:$owner, name:$name) { defaultBranch } }'; Variables = @{ owner = 'octocat'; name = 'Hello-World' } }
110106
)
111107
Invoke-GithubGraphQLParallel -Queries $queries
112108
#>
113109
param(
114-
[Parameter(Mandatory)]
115-
[Hashtable[]] $Queries,
116-
[Switch] $UseFallback
110+
[AllowEmptyCollection()]
111+
[Hashtable[]] $Queries
117112
)
118113

119114
$results = @()
120115
$errors = @()
121116

117+
# Early return for empty or null queries
118+
if ($null -eq $Queries -or $Queries.Count -eq 0) {
119+
return @{ Results = @(); Errors = @(); FallbackUsed = $false }
120+
}
121+
122+
$results = @()
123+
$errors = @()
124+
125+
# Early return for empty queries
126+
if ($Queries.Count -eq 0) {
127+
return @{ Results = @(); Errors = @(); FallbackUsed = $false }
128+
}
129+
130+
# Use Runspaces for parallel execution
131+
$runspacePool = [runspacefactory]::CreateRunspacePool(1, [Math]::Min(5, $Queries.Count))
132+
133+
$results = @()
134+
$errors = @()
135+
122136
# Use Runspaces for parallel execution
123137
$runspacePool = [runspacefactory]::CreateRunspacePool(1, [Math]::Min(5, $Queries.Count))
124138
$runspacePool.Open()
@@ -180,9 +194,8 @@ function Invoke-GithubGraphQLParallel {
180194
$runspacePool.Close()
181195
$runspacePool.Dispose()
182196

183-
if ($errors.Count -gt 0 -and $UseFallback) {
184-
Write-Log "Some GraphQL queries failed, falling back to REST API"
185-
return @{ Results = $results; Errors = $errors; FallbackUsed = $true }
197+
if ($errors.Count -gt 0) {
198+
Write-Log "Some GraphQL queries failed with errors: $($errors.Count)"
186199
}
187200

188201
return @{ Results = $results; Errors = $errors; FallbackUsed = $false }

0 commit comments

Comments
 (0)