What is GraphQL?

Learn about the motivations behind the invention of GraphQL.

GraphQL is a query language that lets us describe the data we want to receive from the API. It gives the client the ability to ask for exactly what they need.

In the illustration below, the GraphQL server returns the exact fields our application is asking for, even though the Book entity has other fields.

Meta (formerly known as Facebook) developed GraphQL in 2012 before being publicly released in 2015. In 2019, it became a foundation. Today, it’s hosted by the Linux foundation, along with other GraphQL projects like GraphiQL, GraphQL.js, Node.js, and many others.

Motivation behind GraphQL

The motivation behind GraphQL was pretty simple: the team at Meta had encountered many problems when trying to get a Facebook user’s news feed. This was because the shape of data was different between what was implemented in the backend and what front-end teams assumed it would be. It was also due to the problems related to underfetching and overfetching.

By working with GraphQL, some of the complexity is moved from the server-side to the client-side, which can be a very good thing for the developer. Many of the mobile phones we use today are more powerful than the PCs we had years ago, which is amazing for us, because now we rely less on the server’s computing power, subsequently lowering the cost of infrastructure. This decrease in ...