5.4 GraphQL History and Analysis

In the early 2010s, Facebook struggled to build out their mobile app [35]. Facebook was traditionally strong at building web-experiences, and, because of this, decided to display web views on mobile phones, instead of building a native experience tailored to this smaller, less powerful device. This caused serious issues for users, as mobile phones couldn’t keep up with the bandwidth and network requirements to display these large web components.

The main problem was Facebook’s News Feed implementation on mobile, as its web views not only required the retrieval of a post, but also significant additional information that needed to be constantly updated, namely comments and likes. Additionally, all of these Facebook posts were nested, interconnected, and recursive, rendering Facebook unable to handle the complexity with their existing APIs, due to a number of the weaknesses we mentioned above about REST, namely roundtrips and verbose responses. Thus, Nick Schrock, Alex Langenfield, Dan Schafer, and Lee Byron, four engineers working on the mobile team at Facebook in 2015, developed GraphQL.

GraphQL is an open-source language for client-side applications to query databases. GraphQL only exposes one endpoint, from which a client can retrieve all of the desired information. A GraphQL request is essentially a string that, when sent to a server, returns JSON back to the client. These responses will take the same shape as the query, so clients know the shape of the data that’s returned from running the query, rendering it significantly easier for client-side developers to write queries, should client-side developers be cognizant of the sorts of data their application requires.

In GraphQL, it is up to the server to grab relevant information and return it to the client, whereas in REST the client needs to make multiple trips to return the desired information. Pushing the burden of data retrieval to the server in this way allows the client to retrieve many resources from the server in a single request. GraphQL is strongly-typed [36]: it allows API users to know exactly what data is available and the formatting of its existence. This renders it significantly easier for clients to figure out how to build their queries and for developers to maintain the API on the backend.

Last updated