Making Open Work
May 8–9, 2017: Training & Tutorials
May 10–11, 2017: Conference
Austin, TX

From REST to GraphQL: Why a query language is perfect for writing APIs

David Celis (GitHub), Garen Torikian (GitHub)
11:00am11:40am Wednesday, May 10, 2017
Adopt This Now
Location: Ballroom F
Level: Intermediate
Average rating: ****.
(4.35, 20 ratings)

Who is this presentation for?

  • API developers

Prerequisite knowledge

  • Basic knowledge of RESTful APIs (useful but not required)

What you'll learn

  • Learn how to leverage GraphQL to build new client-friendly APIs for your applications.

Description

Sixteen years ago, Roy Fielding introduced REST to the world. Originally used to drive the development of HTTP/1.1, it also became the architecture of choice for APIs, and companies like Flickr, Facebook, and Twitter were instrumental in pushing REST as they released APIs for sharing user content. In 2006, Amazon began releasing APIs that would fundamentally change the world of web development and usher in the age of cloud computing. In all this time, our usage of APIs has changed drastically. But the architecture of these APIs hasn’t changed much at all. What does the future of API development look like?

REST is a well-documented and widely adopted standard, but there are areas in which it falls short. Clients often must make many HTTP requests to receive the data they need to render a single view. REST APIs need to be versioned as breaking changes are introduced. Many omit hypermedia links, an important aspect of RESTful architecture. Also, REST is tied to HTTP as its transfer protocol and depends heavily on external addresses like URLs that are expected not to change. Finally, the behavior of REST APIs isn’t inherently discoverable. If a REST API isn’t well documented, it’s very frustrating to write clients to consume it.

Thankfully, a new alternative to RESTful APIs is emerging that can deal with all of these shortcomings and more. Enter GraphQL, a tool written by Facebook to help power its mobile applications. As you might guess from its name, GraphQL is a query language. It’s also perfect as an API layer in ways that REST can’t compete with. GraphQL is strongly typed and hierarchical and allows clients to request exactly the data they need. No more, no less. And because it isn’t tied to any specific storage layer, it works with your existing code and data.

David Celis and Garen Torikian demonstrate how you can use GraphQL to build your APIs and explain why companies like Shopify, Pinterest, and GitHub are choosing GraphQL.

Topics include:

  • Wrapping existing data and Ruby code in a GraphQL API
  • GraphQL’s fully fledged type system
  • How to query for and mutate data using a new GraphQL API
  • GraphQL’s introspection and self-documenting capabilities
Photo of David Celis

David Celis

GitHub

David Celis is a software engineer at GitHub (where he writes APIs) in Portland, OR (where he drinks IPAs). As a platform engineer, he works with GitHub’s API, third-party integrations, webhooks, and, most recently, its early-access GraphQL API. David is on the internet in most places as @davidcelis.

Photo of Garen Torikian

Garen Torikian

GitHub

Garen Torikian wants to help make the world a better place for humans and other sentient beings on earth. Garen’s been programming ever since he learned how to make GIFs for his GeoCities website in the late ’90s. He writes, writes documentation, and writes tooling to help people who write documentation. He was a reader of books long before he was a writer of code. You can find him almost anywhere on the internet by the handle @gjtorikian.