Skip to content

Use repositoryCustomPropertyValues GraphQL field to populate CustomProperties on GitHubRepository #554

@MariusStorhaug

Description

Summary

GitHub's GraphQL API now exposes custom properties directly on the Repository type via the repositoryCustomPropertyValues connection field. This means Get-GitHubRepository can return custom properties inline — eliminating the need for a separate REST call via Get-GitHubRepositoryCustomProperty.

Current behavior

  • Get-GitHubRepository uses GraphQL to fetch repositories, but CustomProperties is always $null because the PropertyToGraphQLMap maps CustomProperties to '' (empty string) and the GraphQL constructor never populates it.
  • To get custom properties, users must make a separate call: Get-GitHubRepositoryCustomProperty -Owner <owner> -Repository <repo>, which uses the REST endpoint GET /repos/{owner}/{repo}/properties/values.

GraphQL schema discovery

Schema introspection confirms two fields on the Repository type:

Field Type Description
repositoryCustomPropertyValue RepositoryCustomPropertyValue A single custom property value
repositoryCustomPropertyValues RepositoryCustomPropertyValueConnection A paginated list of custom property values

The connection node type RepositoryCustomPropertyValue has:

  • propertyName (String!)
  • value (String!)

Example query

{
  repository(owner: "PSModule", name: "GitHub") {
    repositoryCustomPropertyValues(first: 100) {
      nodes {
        propertyName
        value
      }
    }
  }
}

Returns:

{
  "propertyName": "Type",
  "value": "Module"
}

Proposed changes

  1. GitHubRepository.PropertyToGraphQLMap — Update the CustomProperties entry from '' to:

    'repositoryCustomPropertyValues(first: 100) { nodes { propertyName value } }'
    
  2. GitHubRepository GraphQL constructor — Add logic to populate $this.CustomProperties from the GraphQL response, converting the nodes array into the same shape as the REST API returns (or a suitable hashtable/PSCustomObject).

  3. Consider whether Get-GitHubRepositoryCustomProperty should remain as a standalone function for cases where users only need custom properties without fetching the full repository object (it may still be useful).

References

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions