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.
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