Can't query organizations with search type of USER


#1

I am trying to list the repositories of each user.

If I query the following it returns me repositories from organizations as well.

const repoQuery = gql`
  query($name: String!){
    search(query: $name, last: 24, type: REPOSITORY) {
      repositoryCount
      edges {
        node {
          ... on Repository {
            id
            name
            description
            url
        }
      }
    }
  }
}

Since there is no option like isOrganization I can’t tell the difference between users and organizations and when I try to query the username with type: USER I get an empty result.

query ($name: String!) {
  search(query: $name, last: 24, type: USER) {
    edges {
      node {
        ... on User {
          id
          login
          url
          avatarUrl
        }
      }
    }
  }
}  

Is there a solution for this problem?


#2

Hi @jackdave. Thanks for opening this and apologies for the delayed response.

Does querying with the Organization type in the fragment condition return the expected results?

query ($name: String!) {
  search(query: $name, last: 24, type: USER) {
    edges {
      node {
        ... on Organization {
          id
          login
          url
          avatarUrl
        }
      }
    }
  }
}  

#3

I have a similar issue. The problem is that from a URL, it’s impossible to determine whether you’re dealing with a user or an organisation. Take this URL: https://github.com/google

Is “google” a user or an organization? Is there a way the Github API can determine that?