Query teams for a specific user

community-help

#1

I would like to find out the teams the user belongs to, thanks to this, there is a query field in members but it seems we can’t use the team's query field to filter members. In Github UI Teams page, if I input @username it will filter the teams the member username belongs to, but the following doesn’t work in GraphQL :

{
  organization(login:"my-org") {
    teams(first:100,query:"@username") {
      edges {
        node {
          name
          description
        }
      }
    }
  }
}

Is there other way to get the teams for a specific user ?

Currently the following works but needs a filter on client side to keep only items where members is not empty :

{
  organization(login:"my-org") {
    teams(first:100) {
      edges {
        node {
          name
          description
          members(first:1,query:"username"){
            edges {
              node {
                login
              }
            }
          }
        }
      }
    }
  }
}

#2

From Organization, teams takes a userLogins parameter.

Look under teams in https://developer.github.com/v4/reference/object/organization/

userLogins: [String!]
User logins to filter by

#3

@vgough Thanks a lot, it worked great ! :smile: