List non-forked repositories only


#1

How can I list only my original repositories?

I tried:

query { 
  viewer { 
    repositories(first:30 after:"" isFork:false) {
      edges {
        node {
          name
        }
      }
      pageInfo {
        endCursor
      }
    }
  }
}

But it didn’t work. Any tips?


#2

Hey @caarlos0! When you run that query, you should get a response that looks like this:

{
  "data": null,
  "errors": [
    {
      "message": "Field 'repositories' doesn't accept argument 'isFork'",
      "locations": [
        {
          "line": 3,
          "column": 5
        }
      ]
    }
  ]
}

That’ll let you know that isFork isn’t a valid argument for a User’s repositories connection… yet! This is definitely something we want to add to our schema, and we’re tracking this internally. Thanks!


#3

Yes, that’s what I mean by “it didn’t work” hehe

Nice, thanks!

The graphql api is looking very good already =)


#4

Hey @caarlos0! I went and implemented an isFork argument on the User.repositories connection for you

Now you can run a query like this:

query {
  repositoryOwner(login:"charliesome") {
    repositories(first: 3, isFork: false, privacy: PUBLIC, orderBy: { field: CREATED_AT, direction: DESC }) {
      edges {
        node {
          name
        }
      }
    }
  }
}

And that’ll return the 3 most recently pushed public non-forked repos:

{
  "data": {
    "repositoryOwner": {
      "repositories": {
        "edges": [
          {
            "node": {
              "name": "git-cursor-log"
            }
          },
          {
            "node": {
              "name": "arc4-haskell"
            }
          },
          {
            "node": {
              "name": "unwarp"
            }
          }
        ]
      }
    }
  }
}

I hope that helps! :smile:


List repositories filtered by owner and repo name
#5

This rocks! Can we get the same for isPrivate? Linking to the topic: https://platform.github.community/t/how-to-query-with-arguments-to-limit-results


#6

@Gattermeier - There’s now a privacy argument on the repositories connection that takes either PUBLIC or PRIVATE


#7

I am having some issues using this for a organizations repos. It is listing forks no matter the value of isFork. Is this a bug or incorrect usage?

{
  organization(login: "Obsidian-StudiosInc") {
    repositories(first: 20, isFork: false) {
      nodes {
        name
      }
    }
  }
}

#8

Interesting, that looks like a bug. I’ll open up an internal issue to look into this, @wltjr.


#9

Ok should I report others? I also saw issues with sorting not working. I will make a new post so it is not buried in this one.


#10

:heart: Yes please. New issues work great for us so that we can easily import them into our internal trackers.


#11

I am having some issues using this for a organizations repos. It is listing forks no matter the value of isFork. Is this a bug or incorrect usage?

:wave: @wltjr,

This should now be resolved. Would you mind checking? For what it’s worth I found out that this is related to the other issue you opened, Organization repositories orderBy has no effect. I’m working on a fix and should have something reasonably soon.


#12

Yes this is resolved now, only getting non-forked repositories, or forked based on value. Thank you!

I figured the other was likely related, since both applied to organization, seemed it was off for both when working with an org.