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

2 points by geekjock ↗ HN
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?

0 comments

[ 3.5 ms ] story [ 7.0 ms ] thread

No comments yet.