-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Request
Problem: Invoke-GitHubGraphQLQuery throws a terminating error whenever the GraphQL response contains an errors field, even when valid data is also returned. Per the GraphQL specification, a response can contain both data and errors (partial success), and clients should return the data while surfacing the errors as warnings.
Context
When querying fields that may be unavailable for some repositories (e.g., repositoryCustomPropertyValues on repos where the caller lacks permissions), the GraphQL API returns both valid data and errors. The current implementation discards all data and throws, causing unnecessary failures for callers that could use the partial data.
Acceptance criteria
- When GraphQL returns both
dataanderrors, the function emitsWrite-Warningfor each error and returnsdata - When GraphQL returns only
errors(nodata), the function throws a terminating error as before - Warning messages include the error type, message, and path for debugging
Technical decisions
Approach: Check for $null -ne $graphQLResponse.data when errors are present. If data exists, treat as partial success; otherwise treat as full failure.
Warning format: Each partial error emits a separate Write-Warning with type, message, and path. Full failure errors include the full serialized error object for debugging.
Backward compatibility: Full-failure behavior is unchanged. Partial-success is new behavior — previously these would have thrown, so callers that relied on the error will now get data plus warnings instead. This is a net improvement.
Implementation plan
Core changes
- Update
Invoke-GitHubGraphQLQueryerror handling block insrc/functions/public/API/Invoke-GitHubGraphQLQuery.ps1 - Add partial success branch: when
$graphQLResponse.datais not null, emitWrite-Warningfor each error and continue - Keep full failure branch: when no data is returned, throw terminating error with detailed error messages
References
Metadata
Metadata
Assignees
Labels
Type
Projects
Status