GraphQL is taking over APIs

Carlos Morales

Carlos Morales • 2019-02-23

GraphQL is a query language for APIs, which is becoming very popular as we could read in the state of the JS. A GraphQL query specifies exactly what is being fetched and it will return that (no more, no less), this has profound implications.

GraphQL works as a data aggregator, it aggregates multiple queries, while typical REST APIs require loading multiple URLs, GraphQL APIs get all the data in a single request.

Because GraphQL is very flexible, you could modify the query without changing the server GraphQL API. This means adding new fields without impacting existing queries, no need for having new versions or breaking changes.

Experienced teams share their experiences

These are some interesting experiences from well-known companies:

And other companies like IBM, Walmart Labs, Shopify, and many more.

Advantages and disadvantages of GraphQL

Advantages

The two most mentioned advantages are performance and the simplification of APIs:

The advantages of GraphQL are better user experience (UX) and better developer experience (DX)

Disadvantages

As usual in engineering there is no one-size-fits-all solution, so I specially liked the trade-off analysis from Netflix. They mention three disadvantages, although the last one is easily solvable:

Surprisingly, these teams do not mentioned the delay graphQL must add to the system, either it is unnoticeable (<100ms) or the performance gains they mention improve the overall result.

In a nutshell, with graphQL we get better UX and DX with a more complex system. :clap::clap::clap: