From 79fbd3eb75d8dbeaf487ae9dff451d3ab0570bb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Tue, 10 Feb 2026 11:18:22 +0100 Subject: [PATCH] feat(driver_gh): implement Invoke-GitHubUpdateItemValues function with GraphQL integration --- public/driver/driver_gh.ps1 | 99 ++++++++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 30 deletions(-) diff --git a/public/driver/driver_gh.ps1 b/public/driver/driver_gh.ps1 index 391c684..376b4d8 100644 --- a/public/driver/driver_gh.ps1 +++ b/public/driver/driver_gh.ps1 @@ -126,6 +126,74 @@ Updates item values in a GitHub project This is an integration function that is not intended to be used directly by the user. Updates the values of specific fields for an item in a GitHub project. #> +# function Invoke-GitHubUpdateItemValues{ +# param( +# [Parameter(Mandatory=$true)] [string]$ProjectId, +# [Parameter(Mandatory=$true)] [string]$ItemId, +# [Parameter(Mandatory=$true)] [string]$FieldId, +# [Parameter(Mandatory=$true)] [object]$Value, +# [Parameter(Mandatory=$true)] [ValidateSet("singleSelectOptionId", "text", "number", "date", "iterationId")] +# [string]$Type +# ) + +# "ProjectId: $ProjectId, ItemId: $ItemId, FieldId: $FieldId, Value: $Value, Type: $Type" | Write-MyDebug -section "driver_gh" + +# # Use the environmentraviable +# $token = Get-GithubToken +# if(-not $token){ +# throw "GH Cli Auth Token not available. Run 'gh auth login' in your terminal." +# } + +# # Define the GraphQL query with variables +# $mutation = Get-GraphQLString "updateItemValues.mutant" + + + +# # Define the headers for the request +# $headers = @{ +# "Authorization" = "Bearer $token" +# "Content-Type" = "application/json" +# } + +# # Ensure that if the $type is number the value is a number +# # API fails if when updaring a number the value type in the Input payload s not a number +# if($Type -eq "number"){ +# $Value = [decimal]$Value +# } + +# # Define the variables for the request +# $variables = @{ +# input = @{ +# projectId = $ProjectId +# itemId = $ItemId +# fieldId = $FieldId +# value = @{ +# $Type=$Value +# } +# } +# } + +# # Define the body for the request +# $body = @{ +# query= $mutation +# variables = $variables +# } | ConvertTo-Json -Depth 10 + +# # Send the request +# $response = Invoke-RestMethod -Uri 'https://api.github.com/graphql' -Method Post -Body $body -Headers $headers + +# # Check if here are errors +# if($response.errors){ +# $response.errors | ForEach-Object { +# getErrrorString -Errors $response.errors | Write-MyError +# } +# return $null +# } + +# # Return the field names +# return $response +# } Export-ModuleMember -Function Invoke-GitHubUpdateItemValues + function Invoke-GitHubUpdateItemValues{ param( [Parameter(Mandatory=$true)] [string]$ProjectId, @@ -138,23 +206,9 @@ function Invoke-GitHubUpdateItemValues{ "ProjectId: $ProjectId, ItemId: $ItemId, FieldId: $FieldId, Value: $Value, Type: $Type" | Write-MyDebug -section "driver_gh" - # Use the environmentraviable - $token = Get-GithubToken - if(-not $token){ - throw "GH Cli Auth Token not available. Run 'gh auth login' in your terminal." - } - # Define the GraphQL query with variables $mutation = Get-GraphQLString "updateItemValues.mutant" - - - # Define the headers for the request - $headers = @{ - "Authorization" = "Bearer $token" - "Content-Type" = "application/json" - } - # Ensure that if the $type is number the value is a number # API fails if when updaring a number the value type in the Input payload s not a number if($Type -eq "number"){ @@ -173,22 +227,7 @@ function Invoke-GitHubUpdateItemValues{ } } - # Define the body for the request - $body = @{ - query= $mutation - variables = $variables - } | ConvertTo-Json -Depth 10 - - # Send the request - $response = Invoke-RestMethod -Uri 'https://api.github.com/graphql' -Method Post -Body $body -Headers $headers - - # Check if here are errors - if($response.errors){ - $response.errors | ForEach-Object { - getErrrorString -Errors $response.errors | Write-MyError - } - return $null - } + $response = Invoke-GraphQL -Query $mutation -Variables $variables # Return the field names return $response