Introduction GraphQL with Github API

  • Published on

  • View

  • Download


Introduction GraphQL with Github APISansan LT Sansan

Self-Introduction: yonda: 29: Ruby Kaigi :

The GitHub GraphQL API

What is GraphQL ?Facebook GraphAPI REST API

What is GraphQL points better than RESTfull API ? API API

Why github choose GraphQL ?You may be wondering why we chose to start supporting GraphQL. Our API was designed to be RESTful and hypermedia-driven. Were fortunate to have dozens of different open-source clients written in a plethora of languages. Businesses grew around these endpoints.

Like most technology, REST is not perfect and has some drawbacks. Our ambition to change our API focused on solving two problems.

The first was scalability. The REST API is responsible for over 60% of the requests made to our database tier. This is partly because, by its nature, hypermedia navigation requires a client to repeatedly communicate with a server so that it can get all the information it needs. Our responses were bloated and filled with all sorts of *_url hints in the JSON responses to help people continue to navigate through the API to get what they needed. Despite all the information we provided, we heard from integrators that our REST API also wasnt very flexible. It sometimes required two or three separate calls to assemble a complete view of a resource. It seemed like our responses simultaneously sent too much data and didnt include data that consumers needed.

As we began to audit our endpoints in preparation for an APIv4, we encountered our second problem. We wanted to collect some meta-information about our endpoints. For example, we wanted to identify the OAuth scopes required for each endpoint. We wanted to be smarter about how our resources were paginated. We wanted assurances of type-safety for user-supplied parameters. We wanted to generate documentation from our code. We wanted to generate clients instead of manually supplying patches to our Octokit suite. We studied a variety of API specifications built to make some of this easier, but we found that none of the standards totally matched our requirements.

And then we learned about GraphQL.(from

GraphQL Explorer for Github APIgithub GraphQL API explorer

Github API GraphQL

example (at first)

example (multi fields)

example (aliases)

example (like a join of SQL)

example (fragments)

example (variables)

example (directives)

mutation Rails, ruby, python, .net ...etc GraphQL API explorer Rebuild masuidrive GraphQL GraphQL API