simondiep
simondiep

Reputation: 11

How to search Github GraphQL users by Company

I want to find all users that have set their "Company" field in their Github Homepage to "Github". I see it is a defined field in the Github Docs at https://developer.github.com/v4/object/user/. However, I can't seem to search for it.

My current query on https://developer.github.com/v4/explorer/ returns no results

{ search(query: "company:Github", type: USER, first: 100) { userCount edges { node { ... on User { login name company } } } } }

Upvotes: 1

Views: 1501

Answers (1)

Shivam Pandey
Shivam Pandey

Reputation: 3936

To search all users by the company, query on the organization. Currently, you are passing a key-value pair as a string to search for instead of value string. Try this query to get all list of employees who have set their company name Github.

{
  organization(login: "github") {
    email
    members(first: 100) {
      totalCount
      nodes {
        ... on User {
          company
          login
          name
          isEmployee
        }
      }
    }
  }
}

See the results in the attached image: enter image description here

Upvotes: 2

Related Questions