As I’ve mentioned before, GraphQL has become incredibly popular in the last few years.
I consider GraphQL to be the most exciting thing to happen to APIs - there are a ton of benefits to GraphQL and, in fact, I’d go so far to say as that GraphQL is the new REST.
As you probably know, REST is one of the most popular forms of structuring APIs over HTTP. (If not, you can read more about that here)
I’ve used GraphQL for years, and here’s just a few reasons why GraphQL is a game changer in application development today:
GraphQL queries mirror the data they request 🔍#
With GraphQL, no longer will we ever need to make a request from the client for a specific set of data, but where a large amount is unnecessarily returned.
GraphQL queries are strongly typed 💪#
Before we tell our GraphQL API how we want each field in our API to be resolved, we’ll need to tell GraphQL the type of the resolved values of each of the fields. This allows GraphQL to provide descriptive error messages when a query fails based on an incorrect value type.
GraphQL and TypeScript work splendidly together 🚀#
Since GraphQL and TypeScript are both strongly typed languages, they work incredibly well together. In fact, numerous tools exist (like the Apollo Command Line Interface) which allow us to automatically generate TypeScript definitions from a GraphQL API.
GraphQL and Apollo is a magical combination ✨#
Many different tools currently exist around working with GraphQL but none we’ve come across as powerful as the Apollo Platform.
Among a suite of many different tools exists the Apollo Server package where a production-ready and intuitive GraphQL API can be built within a Node.js application.
The Apollo Client library also exists to allow React applications to fetch data from a GraphQL API with complete state management and in a declarative manner (with Hooks!).
GraphQL is battle tested ⚔️#
Tons of organizations have started to adopt GraphQL to power their large scale websites and mobile apps. Here are some recent examples of the many different organizations adopting GraphQL.