GraphQL
GraphQL is a query language for APIs that lets clients specify exactly which data they need from the server, instead of fetching a fixed data structure as with traditional APIs.
How it works
Unlike traditional REST APIs, GraphQL receives queries through a single endpoint and returns only the data fields the client explicitly requests, avoiding both over-fetching and under-fetching. This makes front-end development more flexible and efficient, reduces the number of network requests, and improves application performance.
Examples
- 1.A mobile app loading a user profile page can request just the username and avatar, without fetching the user's entire order history.
- 2.A CMS back end lets editors fetch an article's title, author, and associated tags in a single request.
- 3.An e-commerce front end can combine product details, stock status, and user reviews in one query on the product page.