Unexpected result on search query


#1

Hi,

I was testing search using GraphQL and came across this unexpected behaviour (unexpected to me at least!). I was querying for users that will match my own GitHub username:

{
  search(first:10, query:"pnavarrc", type:USER) {
    edges {
      node {
        ... on User {
          login
        }
      }
    }
  }
}

and got this as the response:

{
  "data": {
    "search": {
      "edges": [
        {
          "node": {
            "login": "pnavarrc"
          }
        },
        {
          "node": {}
        }
      ]
    }
  }
}

The second empty node object is a bit unexpected. After reviewing the docs, I discovered that it corresponds to an organization I own … but that shouldn’t appear on the results, because I explicitely passed the type parameter to make sure it will only return objects of type USER right?

Is this the expected behaviour or a bug?


#3

Hey @pnavarrc,

Thanks for your report! I looked into this, and it looks like it’s actually intended behavior, though poorly documented. An Organization is a special type of user, so that’s why we’re returning Organizations here. In the future we may make a Organization search type and make this more specific, but in the mean time, I’ll update the documentation.


#4

That makes sense, thanks!


#5

We’ve updated the documentation. Thanks for reaching out :slight_smile: