GraphQL is an API query language that simplifies client-side requests. Apps can do a lot of work with just a single query, such as query multiple resources and entities, request data in a specific format, or get the server to perform several operations. With GraphQL, all queries go to a single endpoint on the server. The server parses queries and returns only the requested data in the requested format.
“At its simplest, GraphQL is about asking for specific fields on objects.” - from GraphQL.org
Single endpoints
Let’s say you want to build an invoicing app. It needs to constantly request data for a specific set of invoices. The invoices contain particular items for a specific date range and the app needs current business addresses for each customer.
With REST API, you’d need to make several queries to different endpoints: one for the invoice, one for each customer, and one for each item.
GraphQL requires only a single query, sent to a single endpoint.
Get only the data you need
GraphQL queries are highly customizable. You specify the exact fields and values you want the server to return. Apps get only the data you query for, with no over-fetching or under-fetching.
Develop with any language
GraphQL is language-independent. You can use it with any backend framework or programming language implementation.
Validate queries as you work
Since GraphQL is a type system, everything about it is part of its schema. You can validate queries as you create them with testing tools such as GraphiQL (which has a built-in parser). You can also let the server validate requests against the current schema version.
Everything is documented
Accurate and up-to-date documentation is always available along with the schema.
Simple data hierarchies
GraphQL requests and responses are structured the same way. It naturally follows relationships between attributes.