Reputation: 181
I wanna query all repositories in my organization on github private, i try to use
query {
organization(login:"my-org-name") {
id
name
url
repositories(first:100) {
nodes {
id
name
}
}
}
}
However it returns
{
"data": {
"organization": {
"id": "MDEyOk*********************U4ODUw",
"name": "my-org-name",
"url": "https://github.com/my-org-name",
"repositories": {
"nodes": []
}
}
}
}
can't find any repositories. I test it on Github Developer, https://developer.github.com/v4/explorer/
Upvotes: 15
Views: 11348
Reputation: 11
Try this (type your org instead of your_org
):
{
repositoryOwner(login: "your_org") {
... on Organization {
repositories(first: 100) {
totalCount
pageInfo {
endCursor
hasNextPage
}
nodes {
id
name
stars: stargazerCount
forks: forkCount
created_at: createdAt
organization: owner {
login
}
repo_url: url
}
}
}
}
}
Upvotes: 0
Reputation: 437
You have to be Authenticated to do this request.
url: https://api.github.com/graphql
header: Authorization bearer token
method: POST
query {
viewer {
avatarUrl
login
resourcePath
url
bio
company
createdAt
location
followers(first: 100) {
nodes {
name
url
}
}
repositories(first: 100) {
nodes {
name
description
url
createdAt
collaborators(first: 5) {
nodes {
name
}
totalCount
}
}
totalCount
}
}
}
Upvotes: 1
Reputation: 3786
you can achieve using search
end point (you need to be authenticated)
query myOrgRepos($queryString: String!) {
search(query: $queryString, type: REPOSITORY, first: 10) {
repositoryCount
edges {
node {
... on Repository {
name
}
}
}
}
}
with query variables
{
"queryString": "org:my_org"
}
Note that as expected you do not get the list repositories of your organization, you get the list of your organization list that you have access
Upvotes: 9
Reputation: 6344
The GraphQL Explorer is an OAuth Application that needs to be given permission to access your organization data.
You can grant this access directly for the GraphQL API Explorer or navigate to it from your Settings -> Applications -> Authorized OAuth Apps
Note that a personal access token (PAT) does not have this restriction, so this isn't required for an application using your token.
Upvotes: 5