What is GraphQL?
A quick definition of GraphQL: what it is, what it does, and why developers reach for it instead of plain REST.
Sources
- [1]GraphQLwikipedia
- [2]Graphics processing unitwikipedia
- [3]Graffitiwikipedia
- [4]Automatic Property-based Testing of GraphQL APIsarxiv
- [5]An Empirical Study of GraphQL Schemasarxiv
The short version
GraphQL is a query language for APIs. More precisely, it's a data query and manipulation language that lets a client specify exactly what data it wants to retrieve or modify [Source 1]. A GraphQL server takes that query, pulls data from whatever sources it needs, and returns the result as a unified graph [Source 1].
It's not a database. It's not tied to one either. GraphQL doesn't care if your data lives in Postgres, MongoDB, a REST service, or three of those at once [Source 1].
Why people use it
The pitch is simple: clients ask for precisely the fields they want, nothing more. That means fewer round trips to the server and smaller response payloads compared to typical REST endpoints that return fixed shapes [Source 5]. If you only need a user's name and avatar, you ask for name and avatar. You don't get the other 30 fields you didn't want.
This is why adoption has climbed at major organizations [Source 5].
Want your work in the Learn library? Apply for a hardlocked byline.