dev-tools

GraphQL

GraphQL is a query language for APIs, along with a runtime for executing those queries against your data, originally developed at Facebook and open-sourced in 2015. Its core idea is letting the client specify exactly which fields it needs in a single request, rather than the server dictating a fixed response shape per endpoint — the classic alternative being REST, where fetching a user's profile plus their recent orders might require two separate endpoint calls (or one bloated endpoint that always returns more data than any given screen actually needs). Why it matters for AI/SaaS builders: GraphQL is particularly valuable when multiple different frontends (web, mobile, a partner integration) need different subsets of the same underlying data — each client can request precisely the fields it needs without the backend team having to build and maintain a separate custom endpoint per client need, and it eliminates the common REST problems of "over-fetching" (getting more data than needed) and "under-fetching" (needing multiple round trips to assemble one screen's worth of data). It's also a clean fit for AI agents consuming an API: a single, well-typed GraphQL schema gives a model a complete, self-describing map of exactly what data is available and how it relates, which some AI tooling can introspect directly to generate correct queries without needing separate documentation. How it works: a GraphQL API exposes a single endpoint (typically `/graphql`) and a strongly-typed schema describing every available type, field, and relationship. A client sends a query describing the exact shape of data it wants — including nested relationships in one request — and the server resolves each requested field (often via per-field "resolver" functions that fetch from a database or another service) and returns a JSON response matching precisely the requested shape, no more and no less. Worked example: a mobile app screen needs a user's name, their three most recent orders' totals, and nothing else. Instead of a REST call to `/users/42` (which might return 30 fields including address, billing history, and preferences the screen doesn't need) followed by a second call to `/orders?userId=42`, the mobile client sends a single GraphQL query: `{ user(id: 42) { name orders(limit: 3) { total } } }`. The GraphQL server resolves exactly those fields from the underlying database and returns `{"user": {"name": "Alex Chen", "orders": [{"total": 49.99}, {"total": 120.00}, {"total": 15.50}]}}` — one request, one round trip, precisely the data the screen needs and nothing extraneous.

Related terms

More Dev Tools terms