42

I have a GraphQL query. I cannot understand why it is not working.

{
  repositoryOwner(login: "Naramsim") {
    login
    repositories(first: 3, isFork: true, orderBy: {field: CREATED_AT}) {
      edges {
        node {
          description
        }
      }
    }
  }
}

Link

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
Naramsim
  • 8,059
  • 6
  • 35
  • 43

1 Answers1

85

You've got an error

Argument 'orderBy' on Field 'repositories' has an invalid value.
Expected type 'RepositoryOrder'.

You forget to specify direction which is marked as mandatory. This will work:

{
  repositoryOwner(login: "Naramsim") {
    login
    repositories(first: 3, isFork: true,  orderBy: {field: CREATED_AT, direction: ASC}) {
      edges {
        node {
          description
        }
      }
    }
  }
}
Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
  • can I get all repositories without pagination? – Davi Wesley Aug 04 '19 at 22:24
  • @DaviWesley I think that's best asked in a separate question, if it hasn't been asked already (which it probably has) – RyanQuey Sep 01 '20 at 15:55
  • Hi Alex, What about if I want to change the created_at field with dropdown? Like name etc. I need something dynamically. – Ufuk UYSAL Nov 29 '21 at 21:50
  • @UfukUYSAL this is bit of work. You start with [dynamic react graph](https://stackoverflow.com/a/66811179/1705829) and then move on to the gui with react. As your comment is one year old, maybe you did that? – Timo Dec 02 '22 at 16:25
  • In the ordering, you use `CREATED_AT` with `_`. There is also [`CREATEDAT`](https://gist.github.com/MichaelCurrin/72dea64bad7e285323865788aa5871f6#file-owned_repos-gql) without hiven. What is the diff? – Timo Dec 28 '22 at 21:04
  • Can you point us to the docs where you got the snippet "Argument..." from? I [found](https://docs.github.com/en/graphql/reference/objects#repository) repo object info, but without `orderby`. – Timo Dec 28 '22 at 21:12