Unable to list user organizations


#1

I noticed this at work on GHE, but have a simple sample to reproduce on public GitHub.

I can list my own organizations, but if I query for another user, it returns empty results.

Eg, while logged in as vgough, if I attempt to list orgs for another user in my same org, it returns empty results. This was taken from the public github explorer: https://developer.github.com/v4/explorer/

{
  user(login:"2bithacker") {
    email
    organizations(first:100){
      nodes{
        name
      }
    }
  }
}

Results:

{
  "data": {
    "user": {
      "email": "chip@2bithacker.net",
      "organizations": {
        "nodes": []
      }
    }
  }
}

Querying for org by name also fails.


#2

Hi,

try this

{
  user(login: "torvalds") {
    email
    organizations(first: 100) {
      edges {
        node {
          name
        }
      }
    }
  }
}

Response -

{
  "data": {
    "user": {
      "email": "",
      "organizations": {
        "edges": [
          {
            "node": {
              "name": "DROPCitizenShip"
            }
          }
        ]
      }
    }
  }
}

#3

I get the same result – works for listing my orgs, not for another member of my org. I’ve changed the example to pick the first member that shows up when listing org members, just to demonstrate that I can find members by looking at the org, but can’t find the orgs by looking at members:

{
  me: user(login: "vgough") {
    email
    organizations(first: 100) {
      edges {
        node {
          name
        }
      }
    }
  }
  other: user(login: "napcs") {
    email
    organizations(first: 100) {
      edges {
        node {
          name
        }
      }
    }
  }
  
  organization(login: "DigitalOcean") {
    name
	members(first:1) {
      nodes{
        login
      }
    }
  }
}

Result:

{
  "data": {
    "me": {
      "email": "vgough@pobox.com",
      "organizations": {
        "edges": [
          {
            "node": {
              "name": "DigitalOcean"
            }
          }
        ]
      }
    },
    "other": {
      "email": "info@napcs.com",
      "organizations": {
        "edges": [
          {
            "node": {
              "name": "ECRuby - Chippewa Valley Ruby Users Group"
            }
          }
        ]
      }
    },
    "organization": {
      "name": "DigitalOcean",
      "members": {
        "nodes": [
          {
            "login": "napcs"
          }
        ]
      }
    }
  }
}

#4

Hey @vgough!

Thanks for the bug report here, I think I’ve tracked down the problem, and I think it might be undefined/undocumented/incorrect behavior on our end (it depends on who you talk to I’m sure!).

Right now, the user -> organization (and user -> organizations) connection is explicitly scoped to public organizations only, unless you’re looking at yourself. I’m not completely sure why this is the case, and I’m following up with the team right now to figure that out. I’ll have a more in-depth answer shortly, hopefully!


#5

Hey @vgough!

Pardon the late reply to this issue! We had quite a bit of back and forth about whether this was a bug or not, and what the expected behavior is.

The short of the issue is that, right now, the GraphQL API has the same behavior as the analogous REST endpoint, which only lists public organizations, regardless of the permissions of the viewer. Because your organizations in GHE and github.com are private (or, at least, I assume they are), they’ll only show when you look yourself up and not when you look up other people.

The short-term fix for this in enterprise would be to mark the organizations public (which shouldn’t impact anything if your instance is not publicly available), which would unblock you in Enterprise.

After some back and forth, we think the expected behavior would be to show overlapping organizations as well as public orgs, which would solve this issue for good. I’m working up an Issue on that now, and we’ll update this post when that work has been done.

Let me know if any of this is unclear, or if there’s anything else that doesn’t look right!


#6

Hi @vgough,

I wanted to update you that we deployed a fix recently and now show overlapping organizations as well as public orgs when listing organizations for another user. Let me know if you have any questions.

Cheers,

Lizz


#7

When submitting the following query, it appears that Organizations are not being returned for ‘viewer’:

query {
  user(login: "timjroberts") {
  	organizations(first: 5) {
      edges {
        node {
          id,
          name
        }
      },
      nodes {
        id, name
      }
    }
  },
  viewer {
    organizations(first: 5) {
      edges {
        node {
          id,
          name
        }
      },
      nodes {
        id, name
      }
    }
  }
}

#8

Hi @timjroberts!

I’m unable to reproduce this - very interesting! When I change your query to be my GitHub username, I’m able to see the same Organizations in both the viewer and user connections.

Can you show me the data that query returns for you?


#9

Sure @nickvanw, this is the output I see:

{
  "data": {
    "user": {
      "organizations": {
        "edges": [
          {
            "node": {
              "id": "MDEyOk9yZ2FuaXphdGlvbjIwMDM5ODEw",
              "name": "TabHub"
            }
          },
          {
            "node": {
              "id": "MDEyOk9yZ2FuaXphdGlvbjI3NzcxOTI4",
              "name": "Kwento"
            }
          }
        ],
        "nodes": [
          {
            "id": "MDEyOk9yZ2FuaXphdGlvbjIwMDM5ODEw",
            "name": "TabHub"
          },
          {
            "id": "MDEyOk9yZ2FuaXphdGlvbjI3NzcxOTI4",
            "name": "Kwento"
          }
        ]
      }
    },
    "viewer": {
      "organizations": {
        "edges": [],
        "nodes": []
      }
    }
  }
}

The orgs listed are correct.


#10

I’m currently attempting to get a list of the users organizations and it looks like only orgs that the viewer is a public member of are exposed via the GraphQL query. I’ve added the read:org scope but still only public is made visible

@nickvanw is the issue you’ve raised going to add support to view orgs that the user is a private member of?


#11

Hey @gauntface!

Right now, the expected behavior is that the GraphQL API will show you the list of public organizations that the user is in, as well as any private organizations that have a shared membership between the user that you are using to access the API with, as well as the user you are looking up.

It’s expected behavior that private organizations that the user is in should not show up, unless you are a member as well.

Does that answer your question? If the behavior you’re experiencing is different from what I’ve described, please drop your query + response and we’ll look into it!


#12

Hi!

I am using this account: github.com/chadfurman for the gql explorer

When I run this query:

# Type queries into this side of the screen, and you will
# see intelligent typeaheads aware of the current GraphQL type schema,
# live syntax, and validation errors highlighted within the text.

# We'll get you started with a simple query showing your username!
query {
viewer {
login
organizations (first:50) {
edges {
node {
id
name
}
}
}
}
}

I do not see the organization “Clevertech” even though I am a member (i.e. chadfurman is a member of clevertech) and I do not see any of my repositories in clevertech that I am able to see otherwise by visiting this link:
http://github.com/clevertech/

Any advice?

Thank you for your time.

Best Wishes,
Chad