Developer and Text Tools

How to Explore a GraphQL Schema and Build Queries

Understand GraphQL introspection, read a schema in SDL, build queries field by field with variables and read responses and errors with confidence.

Saizul Amin
Saizul Amin2 Nov 2026 · 4 min read
How to Explore a GraphQL Schema and Build Queries

How to Explore a GraphQL Schema and Build Queries

GraphQL lets a client ask for exactly the fields it needs, in one request, from a typed schema. That power comes with a learning curve: before you can write a good query you need to know which types exist and how they connect. Fortunately GraphQL servers can describe themselves. This guide explains introspection, how to read a schema, and how to turn it into working queries with variables, using the GraphQL Query Builder and Schema Explorer.

Introspection in one paragraph

The GraphQL specification defines special fields that start with two underscores. Querying __schema returns every type, its fields, their arguments and return types, enum values and the root types for queries, mutations and subscriptions. Tools send one long standard query, often called the IntrospectionQuery, and build documentation, autocompletion and code generation from the result. Many production APIs disable introspection for public clients, so teams often keep the result as a JSON file in a schema registry instead.

Reading a schema

The schema definition language (SDL) is the readable form:

  • type defines an object with fields, such as type Country { name: String! capital: String }.
  • input defines an object you send as an argument.
  • enum lists allowed values.
  • interface and union describe fields that can return several types.
  • An exclamation mark means non-null; square brackets mean a list. [String!]! is a non-null list of non-null strings.

Start at the Query type: its fields are the entry points. Follow return types to see what you can select next. Descriptions and @deprecated markers tell you which fields to prefer.

Building a query

A query mirrors the shape of the data you want back. If Query has a field country(code: ID!) that returns Country, you can write:

query Country($code: ID!) { country(code: $code) { name capital currency } }

Every object field needs a selection of sub-fields; you cannot ask for an object without saying which parts. Scalars such as String or Int end the selection. A point-and-click builder helps here: ticking fields writes the braces for you, and declaring variables with the exact argument type avoids the frequent "Variable of type ID used in position expecting ID!" error.

Variables, not string building

Put changing values in variables rather than pasting them into the query text. Variables are typed, sent as a separate JSON object, safe from injection problems and make queries cacheable. The query stays the same; only { "code": "BD" } changes. Name your operations too: an operation name such as GetCountry shows up in server logs and makes debugging much easier.

Reading the response

A GraphQL response has data and possibly errors. Unlike REST, a request can partly succeed: some fields return data while others return null with an error entry that has a message, a path and a location in your query. Always look at the errors list even when the HTTP status is 200. Common causes are permission rules on a field, a missing required argument or a resolver that failed on the server.

Mutations

Mutations change data and are written like queries but start with mutation. They usually take an input object argument and return the changed object, so you can select the fields you want to see after the change. Test them against a development server, never production, until you are sure of the effect.

Good habits

  1. Select only the fields a screen actually uses; GraphQL makes over-fetching optional, so do not reintroduce it.
  2. Avoid very deep nesting in a single query; servers often limit depth and complexity.
  3. Use fragments when several queries share the same selection of fields.
  4. Keep the schema SDL in your repository so changes are visible in code review.
  5. Watch for deprecated fields and plan migrations before they are removed.

Limits

A browser-based explorer can only reach endpoints that accept cross-origin requests and that either allow introspection or let you load a saved schema file. Subscriptions over WebSocket and file uploads need dedicated clients. Query validation happens on the server, so a mistake shows up as a server error message rather than being caught before sending.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages