Thư viện QueriesLấy repository từ GitHub
Lấy repository từ GitHub
Query này kết nối với API GraphQL của GitHub và lấy danh sách các repo của chủ sở hữu được chỉ định.
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
}
}
})
}Và định nghĩa trong wp-config.php:
define( 'GITHUB_ACCESS_TOKEN', '{ your github access token }' );