Drawbacks of REST APIs
REST is good, that is until it becomes a hairball.
Nevertheless, REST’s design with primitive pagination and no support for slicing make it a no-go for complex queries. For example, this GraphQL example below:
where we query movie heroes with their name and the names of the first of two of their friends would take multiple REST API calls to accomplish. More queries only add up to the unreadability of REST’s already ugly syntax.
JSON to the rescue
When JSON first came out, in Steve Jobs’ saying, it was a glass of ice water to all the developers out there in the inter-connected web services hell with SOAP and co.
GraphQL is heavily inspired by JSON’s success, as it uses a similar simple format to define the APIs. Moreover, for the very first time, it encompasses:
- queries (the equivalent of SELECT in SQL),
- mutation (the equivalent of INSERT/UPDATE in SQL)
- and schema.
in a single format, which makes it uniquely singular to define and use web services.
GraphQL is still work-in-progress for the most part, but it is a good start. The website claims it has already been explored or used by Yelp, Intuit, Pinterest and Coursera. However, its success will only depend on the indie developers who can up the ante with new tools, implementations, and specs around current drafts.