Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 3

Fetch all permissions for a single user

I'm looking to retrieve all the repo permissions for a user.


Effectively something that I could massage to produce:


"login": "myUser",
"name": "myUsername", "repositories":[ { "name": "myRepo" "permissions":[ { "permission":"ADMIN", "permissionSources": ..... }, { "permission":"READ", "permissionSources": ..... } ] } ] }


The closest thing I have so far is to:

  • lookup my user,
  • iterate through the user's repos (unfortunately the collection here doesn't have all the nice details that RepositoryCollaboratorEdge has)
  • iterate through those repos' collaborators
  • get permission and permission sources


But the problem is I get ALL of the collaborators for the repo on the third step. Is there a way to filter down to just the current user somehow? Or perhaps there is another way to go about this?


Here's the query I'm describing:



query {
  user( login: myuser ) {
    repositories(first:100, affiliations:[OWNER, ORGANIZATION_MEMBER, COLLABORATOR], ownerAffiliations:[OWNER, ORGANIZATION_MEMBER, COLLABORATOR] ) {
      edges {
        node {
	  collaborators ( first: 100 ){ 
	    edges {
	      permissionSources {
                source { 
	 	  ... on Organization { id name }
		  ... on Repository { id name nameWithOwner }
		  ... on Team { id name slug } 






2 Replies
Community Manager
Message 2 of 3

Re: Fetch all permissions for a single user

It looks like the `collaborators` connection on `Repository` allows you to add a `query` parameter to filter by username.


Let us know if you have more questions.

Ground Controller Lvl 1
Message 3 of 3

Re: Fetch all permissions for a single user

I also want to know the same. Kindly Guide me about APK Street