GraphQL

GraphQL is an open-source query language that allows developers to consume, construct, and create APIs in their own unique way.

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:

  1. First, specific data is requested from the client via a query to GraphQL server.
  2. To retrieve that data, a function on the GraphQL server is invoked.
  3. Lastly, GraphQL server returns the specific data requested by the client.

Who Is Using GraphQL?

GraphQL is used by small and large businesses. Some bigger companies include Airbnb, Lyft, GitHub, Twitter, Paypal, and Shopify. More information can be found here.

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn Open Source on Codecademy