Ask HN: Is it GraphQL best practice to limit root query types?

https://news.ycombinator.com/item?id=17376174
by geekjock • 8 years ago
2 0 8 years ago

I was looking at the GitHub GraphQL API (https://developer.github.com/v4/query) and noticed that they only expose a few root query types.

For example, to get a pull request you must use the `repository` Query type and access a pull request through the `Repository` object fields.

  {
    repository(name: 'test') {
      pull_request(number: 2) {
        title
      }
    }
  }
You can't just access a pull request by ID via a root query type:
  {
    pull_request(id: 12345) {
      title
    }
  }
Is this a recommended practice? Is there an argument for limiting root query types in favor of using nested object types to keep the schema cleaner?

Related Stories

Loading related stories...

Source preview

news.ycombinator.com