How it works
Instead of multiple fixed endpoints, GraphQL exposes a single endpoint where the client sends a query describing the data it wants. The server responds with only those fields, avoiding over-fetching (too much data) and under-fetching (too little data). It also supports mutations and real-time subscriptions.
Practical example
A profile screen needs the user's name and avatar. With REST, the endpoint /usuarios/42 returns dozens of fields. With GraphQL, the query asks for just name and avatar, and the response is minimal, saving bandwidth.
What it's for
It's useful in apps with many screens and variable data needs, such as mobile apps and complex front ends. For AI APIs, it can reduce traffic by requesting only the relevant fields from the response.
When not to use
For simple APIs with few endpoints, REST can be more straightforward. GraphQL requires more schema planning and can increase server complexity.