GraphQL repo query is giving me wrong result


#1

When I send this query

{
  user(login: "laike9m") {
    repositories(first: 3, isFork: false, orderBy: {field: STARGAZERS, direction: DESC}) {
      nodes {
        name
        owner {
          login
        }
      }
    }
  }
}

I was meant to fetch repos of my own. But the result contains a forked repo “zhihu-py3”

{
  "data": {
    "user": {
      "repositories": {
        "nodes": [
          {
            "name": "zhihu-py3",
            "owner": {
              "login": "7sDream"   // this is obviously wrong since isFork=false
            }
          },
          {
            "name": "pdir2",
            "owner": {
              "login": "laike9m"
            }
          },
          {
            "name": "ezcf",
            "owner": {
              "login": "laike9m"
            }
          }
        ]
      }
    }
  }
}

I don’t know if it’s a bug or something. Here’s my forked repo zhihu-py3.


#2

Hi @laike9m

By default, the repositories connection on User fetches both owned repositories and repositories you’re a collaborator on. It seems like you’re listed as a collaborator on that repository.

To just get repo’s you own, you can add the affiliations: OWNER argument to the repositories connection!

Let me know if you have any other questions :slight_smile:


#3

Yeah it no longer shows forked projects, Thanks you!