Understanding Introspection: How GraphQL Discovers Your Schema
Learn how introspection enables GraphQL clients to discover API capabilities automatically, and master the documentation tab in Apollo Sandbox.

Previously in this course, we covered Using Apollo Sandbox: Testing Your Local GraphQL API. While we used that tool to execute queries, we didn't fully explore how the Sandbox knows exactly which fields and types are available to you. That magic is powered by Introspection.
In this lesson, we’ll look under the hood to see how your server explains its own structure to the outside world.
What is Introspection?
Introspection is a native GraphQL feature that allows a client to query the server for information about the schema. It turns your API into a "self-documenting" system.
When you connect a tool like Apollo Sandbox or Postman to your server, those tools send a massive, hidden query to a special set of internal fields (starting with __). The server responds with a JSON object describing every Type, Query, Mutation, and Scalar in your schema.
Because you already defined your types in your typeDefs (as discussed in Defining the TypeDefs for your Apollo Server Project), the server has all the data it needs to answer these requests automatically.
The Introspection Flow
- Client Request: The IDE sends an
__schemaquery to your server. - Server Response: Your server returns a complete description of your SDL.
- UI Generation: The client tool parses that JSON to build the "Documentation" tab, type-ahead suggestions, and auto-complete features.
Exploring with the Documentation Tab

You don't need to write the __schema query yourself. In Using Apollo Sandbox: Testing Your Local GraphQL API, you likely noticed the sidebar on the right side of the screen.
Step-by-Step: Using the Sandbox Documentation
- Start your local server (
npm start). - Open your Apollo Sandbox URL in your browser.
- Click on the Documentation tab (usually a book or list icon in the right-hand sidebar).
- Click on
Query. You will see a list of every field currently defined in your Understanding the GraphQL Schema: Building Your API Contract lesson. - Click on a specific type (e.g.,
UserorProduct). You can see the fields, their return types, and whether they are nullable or lists.
This documentation is generated in real-time. If you add a new field to your typeDefs and restart your server, the documentation tab updates instantly.
How Introspection Works: A Conceptual Example
If you were to peek behind the curtain, a basic introspection query looks like this:
GraphQLquery { __schema { types { name kind fields { name type { name } } } } }
When the client executes this, the server traverses your schema definition and returns a structured map of your API. This is why you don't need to manually write Swagger or OpenAPI docs for GraphQL—the schema is the documentation.
Hands-on Exercise
- Open your current project in your editor.
- Add a new, temporary field to your
Querytype in yourtypeDefsfile (e.g.,hello: String). - Save the file and ensure your server restarts.
- Refresh your Apollo Sandbox.
- Navigate to the Documentation tab. Search for the
Queryobject and verify that yourhellofield now appears there automatically.
Common Pitfalls
- Forgetting to Restart: If you change your schema but don't restart your Node.js server, the introspection data will remain stale. Always check your terminal to ensure the server picked up your changes.
- Assuming Documentation is "Hand-Written": New developers often try to create static README files for their APIs. In GraphQL, maintain the SDL—the documentation will take care of itself.
- Security Concerns: In production environments, you might want to disable introspection to prevent malicious users from mapping out your entire internal data structure. For more on this, see GraphQL security: Hardening Schema Exposure Against Introspection.
FAQ
Q: Does introspection affect performance? A: It adds a tiny bit of overhead during the initial connection of the IDE, but it does not affect standard query execution performance.
Q: Can I turn off introspection?
A: Yes, most libraries allow you to set an introspection: false flag in your server configuration. This is a common security hardening step for public-facing APIs.
Q: Does it show my resolvers?
A: No. Introspection only shows the schema contract (the typeDefs). It reveals nothing about your database logic, your secret keys, or how the data is fetched.
Recap
Introspection is the bridge between your server's code and your client's developer experience. It allows tools to read your schema contract automatically, powering the documentation tab in Sandbox and enabling smart auto-complete features. As you continue building your API, remember that your typeDefs are not just code—they are the source of truth for your documentation.
Up next: Querying Static Data — we'll move beyond the schema and start returning actual data from our server to the client.
Work with me

Laravel REST API Development
Clean, secure, well-documented Laravel REST APIs — the backend engine for your app, mobile client, or SaaS. Built by an API specialist.

Headless WordPress + Next.js Frontend Development
Keep WordPress for content, get a lightning-fast Next.js frontend. The best of both worlds — familiar editing, modern speed.

