Queries Library
Queries LibraryFetch repositories from GitHub

Fetch repositories from GitHub

This query connects to GitHub's GraphQL API and retrieves the list of repos for the indicated owner.

query FetchGitHubRepositories(
  $login: String!
  $numberRepos: Int! = 100
) {
  githubAccessToken: _env(name: "GITHUB_ACCESS_TOKEN")
    @remove
 
  _sendGraphQLHTTPRequest(input:{
    endpoint: "https://api.github.com/graphql",
    query: """
    
query GetRepositoriesByOwner($login: String!, $numberRepos: Int!) {
  repositoryOwner(login: $login) {
    repositories(first: $numberRepos) {
      nodes {
        id
        name
        description
      }
    }
  }
}
 
    """,
    variables: [
      {
        name: "login",
        value: $login
      },
      {
        name: "numberRepos",
        value: $numberRepos
      }
    ],
    options: {
      auth: {
        password: $__githubAccessToken
      }
    }
  })
}

And define in wp-config.php:

define( 'GITHUB_ACCESS_TOKEN', '{ your github access token }' );