Skip to content

Commit 79ce2d4

Browse files
author
James Brundage
committed
fix: Get-GQL can -Cache a parameterized query ( Fixes #31 )
It can, but it will not by default unless -Cache is passed.
1 parent 4773f03 commit 79ce2d4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Commands/Get-GQL.ps1

+4-4
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,15 @@ function Get-GQL
168168
$Cache = $true
169169
}
170170

171+
$queryCacheKey = "$gqlQuery$(if ($Parameter) { $Parameter | ConvertTo-Json -Depth 10})"
171172
if ($Cache -and -not $script:GraphQLOutputCache) {
172173
$script:GraphQLOutputCache = [Ordered]@{}
173174
}
174175

175-
if ($script:GraphQLOutputCache.$gqlQuery -and
176-
-not $Parameter.Count -and
176+
if ($script:GraphQLOutputCache.$queryCacheKey -and
177177
-not $Refresh
178178
) {
179-
$script:GraphQLOutputCache.$gqlQuery
179+
$script:GraphQLOutputCache.$queryCacheKey
180180
continue nextQuery
181181
}
182182

@@ -240,7 +240,7 @@ function Get-GQL
240240
}
241241
}
242242
if ($Cache) {
243-
$script:GraphQLOutputCache[$gqlQuery] = $gqlOutput
243+
$script:GraphQLOutputCache[$queryCacheKey] = $gqlOutput
244244
}
245245
if ($queryOutPath) {
246246
New-Item -ItemType File -Path $queryOutPath -Force -Value (

0 commit comments

Comments
 (0)