REST 2.0 Is Here and Its Name Is GraphQL

From SitePoint
May 17, 2017 - 4:00pm
GraphQL is a query language for APIs. Although it's fundamentally different than REST, GraphQL can replace serve as an alternative to REST that offers performance, a great developer experience, and very powerful tools. Throughout this article, we're going to look at how you might tackle a few common use-cases with REST and GraphQL. This article comes complete with three projects. You will find the code for REST and GraphQL APIs that serve information about popular movies and actors as well as a simple frontend app built with HTML and jQuery. We're going to use these APIs to look into how these technologies are different so that we can identify their strengths and weaknesses. To start, however, let's set the stage by taking a quick look at how these technologies came to be. The Early Days of the Web The early days of the web were simple. Web applications began as static HTML documents served over the early internet. Websites advanced to include dynamic content stored in databases (e.g. SQL) and used JavaScript to add interactivity. The vast majority of web content was viewed through web browsers on desktop computers and all was good with the world. REST: The Rise of the API Fast forward to 2007 when Steve Jobs introduced the iPhone. In addition to the far-reaching impacts that the smartphone would have on the world, culture, and communications, it also made developers' lives a lot more complicated. The smartphone disrupted the development status quo. In a few short years, we suddenly had desktops, iPhones, Androids, and tablets. In response, developers started using RESTful APIs to serve data to applications of all shapes and sizes. The new development model looked something like this: GraphQL: The Evolution of the API GraphQL is a query language for APIs that was designed and open-sourced by Facebook. You can think of GraphQL as an alternative to REST for building APIs. Whereas REST is a conceptual model that you can use to design and implement your API, GraphQL is a standardized language, type system, and specification that creates a strong contract between client and server. Having a standard language through which all of our devices communicate simplifies the process of creating large, cross-platform applications. With GraphQL our diagram simplifies: GraphQL vs REST Throughout the rest of this tutorial (no pun intended), I encourage you to follow al

Continue reading this article »