API Design

What Is GraphQL Used For? Playground and Python Examples

What is GraphQL used for in 2026? See real use cases, why GraphQL Playground is old, and a working Python code example.

SA
Samer Alsayegh
Founder
Published
5 min read

GraphQL is used for fetching exactly the data a client asks for, in one request, across mobile apps, content-heavy websites, and any API with deeply nested relationships. It's a query language and runtime, not a database or a specific product, so it sits in front of whatever data source already exists.

One correction before anything else: GraphQL Playground, the tool most tutorials still screenshot, is deprecated. If you're setting up a new project, GraphiQL 2.0 or Apollo Sandbox are the tools actually maintained in 2026.

What Problems Does GraphQL Actually Solve?

Two problems, specifically. Overfetching: a REST endpoint returns a fixed shape, so a mobile client that only needs a post's title still downloads its full body and comments. Underfetching: a page needing data from three REST endpoints needs three round trips, or a backend-for-frontend layer to combine them.

GraphQL fixes both by letting the client name the exact fields it wants, from as many linked types as it wants, in one request.

query MobileFeed {
  entries(limit: 10) {
    title
    slug
    author { name }
  }
}

That single query replaces what would be a list endpoint call plus a per-author lookup in a typical REST setup.

Where Is GraphQL Actually Used in Production?

Content APIs are a strong fit. A page's data needs shift by client, a mobile app needs less than a desktop site, and by page, a list view needs less than a detail view. Draftbase's delivery API ships GraphQL for exactly this reason, alongside REST for cases that don't need field-level control.

E-commerce product catalogs use it for the same reason. A search results page needs a thin slice of a product's fields. A product detail page needs the full set. GraphQL serves both from one schema, no second endpoint required.

Internal developer tools and admin dashboards are a third common fit. They tend to query deeply nested, related data, a user, their org, their org's billing plan, which would otherwise mean stacking REST calls.

Where GraphQL is usually the wrong call

A simple CRUD API with one client and stable, predictable responses gains little from GraphQL's flexibility. It picks up real cost instead: schema design, resolver performance, and a steeper learning curve for a small team. Plain REST or even a single hand-rolled endpoint often wins there.

GraphQL Playground Is Deprecated: What to Use Instead

GraphQL Playground stopped receiving updates, and using it in a new project means running unmaintained, unpatched tooling. Two replacements cover almost every use case in 2026.

GraphiQL 2.0 is the lighter option: open-source, embeddable in your own app, and focused purely on writing and testing queries against a schema.

Apollo Sandbox needs no account and no setup. Point it at any local or remote GraphQL server with introspection enabled. It loads the schema automatically (Apollo blog). For most teams testing against a live server, it's the faster path to a first working query.

How Do I Query GraphQL from Python?

The gql library is the standard client for Python, supporting both sync and async execution, schema validation, and file uploads (graphql-python/gql).

from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

transport = AIOHTTPTransport(
    url="https://api.draftbase.co/delivery/graphql",
    headers={"Authorization": "Bearer YOUR_DELIVERY_KEY"},
)
client = Client(transport=transport, fetch_schema_from_transport=True)

query = gql("""
    query GetEntries($limit: Int!) {
        entries(limit: $limit) { title slug }
    }
""")

result = client.execute(query, variable_values={"limit": 10})

fetch_schema_from_transport=True pulls the live schema via introspection. The client then validates queries locally before sending them, catching a typo'd field name before it becomes a wasted round trip.

Do I Need to Learn GraphQL Query Syntax Separately?

Yes, but it's a small surface. A GraphQL request wraps a query string in a JSON body, and the full breakdown of that split covers variables, mutations, and subscriptions in depth. The syntax itself is closer to JSON with fewer punctuation marks than it is to a new programming language.

Most teams learn it by reading an existing schema in GraphiQL or Apollo Sandbox rather than a syntax reference. Both tools autocomplete field names from the live schema, so writing a first query is closer to exploring a tree than memorizing grammar.

What Does a Typical GraphQL Response Look Like?

A response mirrors the shape of the query, wrapped in a data key. Errors, if any, land in a separate errors array alongside data, not instead of it, since GraphQL can return partial data with partial errors in the same response.

{
  "data": {
    "entries": [
      { "title": "Launch week", "slug": "launch-week" }
    ]
  }
}

That partial-success shape is different from REST's all-or-nothing status code model, and it's worth handling explicitly in client code rather than assuming a 200 status means every field resolved.

The Underused Angle

Most "what is GraphQL used for" posts list use cases and skip the tooling churn underneath them. GraphQL Playground's deprecation is a real, dated fact, not a minor detail, and a surprising number of 2024-era tutorials still tell readers to install it. Following stale advice here means debugging a broken setup before writing a single query.

The same churn applies to client libraries. Apollo Client's bundle size and provider pattern make sense for a large React app. Following a general "how to use GraphQL" guide into Apollo for a one-off script picks up 338KB and a setup pattern. A lighter tool like graphql-request or Python's gql skips both entirely.

Conclusion

GraphQL is used wherever a client's data needs vary by page or platform: content APIs, product catalogs, and internal tools with deep relationships. Skip it for simple, stable CRUD APIs where REST's fixed shape is a feature, not a limit. Building a content-driven app? Draftbase's GraphQL and REST delivery API ships both from one content model. You're not locked into a tooling decision made at project setup.

Ship content that's built to be found

Draftbase generates schema, structured data, and a fast MDX editor for every post.

Frequently asked questions

What is GraphQL used for?

Getting exactly the data a client needs, in one request. It fits content APIs, product catalogs, and internal tools with related data with many nested levels.

Is GraphQL Playground still supported?

No. GraphQL Playground stopped receiving updates. Use GraphiQL 2.0 or Apollo Sandbox instead. Both test queries against a live schema.

What Python library should I use for GraphQL?

The gql library. It supports sync and async processing, schema validation, and file uploads. It works against any GraphQL endpoint.

Does GraphQL replace REST entirely?

No. A simple, stable CRUD API with one client often does better with plain REST, too. GraphQL earns its cost when needs vary by page or client.

What does a GraphQL error response look like?

Errors land in a separate errors array next to data, not instead of it. A response can carry partial data and partial errors at the same time.

SA
Samer Alsayegh
Founder at Draftbase

Samer is a software engineer and entrepreneur, founder of Draftbase and Ezi Home Services, building technology that simplifies home services. Passionate about software, APIs, automation, and creating products that solve real-world problems.

graphqlpythonapi-design

Related posts

Draftbase is a headless CMS built for React devs.