# GraphQL

URL: https://softwaredictionary.org/terms/graphql
Category: Backend & APIs
Last updated: 2026-09-29
Pronunciation: GRAF-kyoo-EL

In short: GraphQL is a query language and runtime for APIs that lets clients request exactly the data they need, often from a single endpoint in a single request.

## What is GraphQL?

GraphQL is a way to build and use APIs in which the client writes a query describing the exact shape of the data it wants, and the server returns JSON in that same shape. It was created at Facebook in 2012, released as open source in 2015, and is now maintained by the GraphQL Foundation.

Every GraphQL API is built around a schema, a typed description of all the data and operations it offers. Clients send queries to read data, mutations to change it, and subscriptions to receive real-time updates. On the server, small functions called resolvers fetch the value for each field from a database, another API, or any other source.

A helpful analogy is a buffet versus a set menu. A REST endpoint is like a set menu that always serves the same plate, while GraphQL lets you choose exactly which dishes go on your plate. This is especially useful for mobile apps and complex user interfaces that need data from many related objects at once.

GraphQL is not a database and does not replace SQL; it sits in front of your data sources as an API layer. Compared with REST, it avoids over-fetching (receiving fields you don't need) and under-fetching (needing several requests to get everything), but it makes HTTP caching and rate limiting harder because most requests go to one endpoint.

## Key takeaways

- Clients specify exactly which fields they want in the response.
- A typed schema describes all available data and operations.
- Queries read data, mutations change it, and subscriptions stream updates.
- Most GraphQL APIs expose a single endpoint, often `/graphql`.
- GraphQL is an API layer, not a database.

## Example: A GraphQL query for nested data

```graphql
# Ask for a user's name and the titles of their 3 latest posts
query {
  user(id: "42") {
    name
    posts(last: 3) {
      title
    }
  }
}

# The response is JSON with exactly the same shape:
# { "data": { "user": { "name": "Ada", "posts": [{ "title": "..." }] } } }
```

## Frequently asked questions

**Is GraphQL better than REST?**

Neither is better in every case. GraphQL shines when clients need flexible, nested data from many sources, while REST is simpler to build, cache, and monitor for straightforward resources.

**Is GraphQL a database?**

No. GraphQL is a query language for APIs; the server's resolvers fetch the actual data from databases, other services, or files behind the scenes.

**Does GraphQL use HTTP?**

Usually, yes. Most GraphQL APIs receive queries as HTTP `POST` requests to a single endpoint, although the specification itself does not require a particular transport.

## Sources

- [GraphQL Specification](https://spec.graphql.org/)

---

Software Dictionary: https://softwaredictionary.org/ · https://softwaredictionary.org/llms.txt
