GraphQL introspection: query a schema and choose what to expose
GraphQL introspection lets a client ask an API for schema information such as types, fields, arguments, and descriptions. schema and type explore the schema; typename identifies the concrete type of an object in a response. Schema discovery helps development tools and documentation, but whether to enable it in production depends on the API’s audience and tooling needs. Disabling it reduces discoverability; it does not replace data authorization.
GraphQL introspection lets a client ask an API for schema information such as types, fields, arguments, and descriptions. __schema and __type explore the schema; __typename identifies the concrete type of an object in a response. Schema discovery helps development tools and documentation, but whether to enable it in production depends on the API’s audience and tooling needs. Disabling it reduces discoverability; it does not replace data authorization.
Distinguish two kinds of introspection
Schema introspection queries available types, fields, descriptions, deprecation status, and other metadata through the GraphQL meta-fields __schema and __type. A GraphiQL interface or IDE can use this information for autocomplete and documentation. Full introspection queries can be deeply nested, so their responses can grow large.
__typename has a different purpose. It returns the concrete object type for an Object, Interface, or Union result. Clients can use it to branch on possible types or maintain normalized caches. Do not treat it as the same feature as enumerating the schema with __schema.
query Search($text: String!) {
search(text: $text) {
__typename
... on Product { id name }
... on Review { id rating }
}
}Here __typename tells the client whether each search result is a Product or a Review. GraphQL implementations provide this meta-field; developers do not add it as an ordinary API field.
To explore the schema, a client can query __schema:
query SchemaTypes {
__schema {
types { name }
queryType { name }
}
}__schema and __type(name: ...) are available from the query root. Tools can follow __Type.kind and ofType to interpret List and Non-Null wrappers, and can read field descriptions and deprecation information.
Handle development and production differently
During development, introspection supports schema explorers, IDE autocomplete, documentation browsers, and client-code tools. Apollo Server’s current API reference says introspection defaults to enabled unless NODE_ENV=production; in production, its default is disabled. Apollo GraphOS Router also says it does not resolve introspection queries by default. Check defaults for other servers, router versions, and configurations.
The production choice depends on the API:
**Internal first-party API:** If deployed clients already know their operations from the build and open-ended discovery is unnecessary, you can restrict introspection on the production endpoint and provide schema access to developer tools through a registry or build artifact.
**Public developer API:** If schema discovery is part of the intended developer experience or contract, exposing introspection may be appropriate. Apply request/cost limits and authorization, and review the schema for sensitive descriptions or internal-only types.
**Staging or restricted environment:** If introspection is needed, restrict access with authentication or network policy and confirm the settings differ from production as intended.
Schema visibility and data access are separate. Introspection reveals the API’s structure; it does not itself grant permission to read data through resolvers. Conversely, disabling introspection does not prevent all schema details from being inferred from API paths, client bundles, errors, documentation, or other behavior. Treat disabling it as a discoverability layer, not a substitute for authorization.
Before disabling it
When introspection is disabled, tools that connect directly to the server to read its schema—such as an Explorer, GraphQL Playground, or IDE plugin—might stop working or lose autocomplete. With Apollo’s schema registry, a team can explore and manage the registered schema without querying the production endpoint. In other setups, a version-controlled SDL file or internal documentation may serve as an alternative.
Verify the change in each environment. In development, confirm that tools can still read the schema. In production, confirm that the introspection query is rejected as intended, while ordinary queries still follow field and object authorization rules. Setting names and behavior vary by implementation; do not copy Apollo configuration directly to another server.
Checklist
Which clients and tools depend on runtime schema introspection?
Is the API public to developers or restricted to first-party apps?
Have you reviewed whether schema descriptions and fields are appropriate to expose?
If production introspection is disabled, is there a schema registry or SDL alternative?
Are authentication and authorization for data fields enforced independently?
Have you checked introspection settings and access for development, staging, and production?
Are resource limits applied to deep introspection and ordinary operations?
Sources
[Official GraphQL introspection guide](https://graphql.org/learn/introspection/)
[GraphQL September 2026 specification: introspection system](https://spec.graphql.org/September2026/#sec-Introspection)
[Apollo Graph Security: managing production discoverability](https://www.apollographql.com/docs/graphos/platform/security/overview)
[Apollo Server API: introspection defaults](https://www.apollographql.com/docs/apollo-server/api/apollo-server)
[Apollo Router YAML configuration: introspection and depth limits](https://www.apollographql.com/docs/graphos/routing/v3/configuration/yaml)
[Apollo production readiness checklist](https://www.apollographql.com/docs/graphos/platform/production-readiness/checklist)