History of GraphQL
GraphQL was initially developed by Meta (formerly Facebook) in 2012 to address internal issues with their mobile applications. As an alternative to representational state transfer (REST) architecture, GraphQL became open source in 2015. Consequently, because GraphQL makes data transfers more efficient, it reduced network usage for Meta’s mobile applications drastically. Since then, GraphQL has attracted a large number of developers and is becoming increasingly popular for client-server communication.
Why Adopt GraphQL?
Before adopting GraphQL, developers should be familiar with RESTful architecture.
- One of REST’s disadvantages is it can result in an excessive number of HTTP queries or too much data being fetched.
- Alternatively, GraphQL allows developers to ask for specific data instead of fetching a large object with all of the data every time. There is no room for errors like underfetching and overfetching with GraphQL.
- Finally, GraphQL allows developers to easily integrate with databases, JSON files, RESTful APIs, and cloud services.
How GraphQL Works
A common GraphQL workflow can be seen below:
- First, specific data is requested from the client via a query to GraphQL server.
- To retrieve that data, a function on the GraphQL server is invoked.
- Lastly, GraphQL server returns the specific data requested by the client.