# GraphQL

> A way to ask an API for just the fields you want, in one go.

**Field:** Software Development  
**Category:** APIs  
**Also known as:** GraphQL API, Graph Query Language

## Think of it like

Think of it like a buffet. You fill your plate with just the dishes you want, in one trip.

## Definition

GraphQL is a query language that lets a client ask for exactly the fields it wants. All requests go to one address, and each one says the shape of the answer it expects. One request can gather data that a REST API would spread across several calls. The server publishes a schema that lists every type and field you can ask for. Facebook built it and released it to the public in 2015.

## Example

Lucy's phone app needs a user's name and their last 3 orders. One GraphQL query fetches both, with no extra fields.

## Example code

```graphql
{
  user(id: 42) {
    name
    orders(last: 3) { total }
  }
}
```

Ask for a name and three order totals, and get exactly that back.

## Why it matters

Apps on slow phone networks can fetch just what one screen needs in a single trip.

## Common mistake

Letting clients ask for deeply nested data with no limits. One query can then ask for millions of rows.

## Three principles

- **Ask for exact fields.** No more, no less.
- **One address.** Every query goes there.
- **A schema lists it all.** Every type and field.

## Related terms

- [REST API](https://learn.benibix.com/term/development/rest-api)
- [Application Programming Interface (API)](https://learn.benibix.com/term/development/api)
- [API Endpoint](https://learn.benibix.com/term/development/endpoint)
- [JavaScript Object Notation (JSON)](https://learn.benibix.com/term/development/json)

## Told apart from

- [REST vs GraphQL](https://learn.benibix.com/compare/rest-vs-graphql): A REST API gives every thing its own address and uses HTTP methods on it. GraphQL sends every query to one address and lets the client pick the exact fields. REST is simpler to cache; GraphQL saves trips on a slow phone.

---

Source: https://learn.benibix.com/term/development/graphql
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
