Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

GraphQL · Function

introspectionFromSchema

GraphQL introspection lets clients query an API’s schema itself. The __schema field exposes schema-level information, while related introspection fields reveal type details and runtime type names.

How it works

GraphQL exposes schema metadata through introspection fields. Query __schema from the query root to inspect the root operation types and the types defined by the service; query __type when you need details for one named type.

Syntax

query { __schema { ... } }

Returns

A response containing the schema metadata selected through the __schema introspection field.

Key points

  • Introspection uses normal GraphQL queries to examine an API's schema.
  • The __schema meta-field is available on the query root and exposes schema-level metadata.
  • Schema introspection can reveal more than names, including structural metadata selected through the introspection types.
  • Names beginning with two underscores identify GraphQL's built-in introspection types and meta-fields.
  • A client can request information about schema elements through __schema.

Common mistakes

  • Use __schema from the query root; it is not an ordinary application field that can be placed arbitrarily.

Example: Inspect a schema

query IntrospectSchema {
  __schema {
    queryType { name }
    types { name kind }
  }
}

Run this query against a GraphQL endpoint to discover the query root and the schema's available types.

When to use it

Schema discovery

Explore an unfamiliar GraphQL API before writing operations.

Developer tooling

Build GraphQL IDE features such as autocomplete and documentation panels.

Documentation generation

Generate reference documentation from types, fields, and descriptions.

Interview questions

QHow does GraphQL introspection let a client discover an API?

A client can query the __schema field on the query root to obtain information about the GraphQL service's schema. The result can include operation root types and the schema's types, fields, arguments, and descriptions.

Follow-up: How would you inspect one specific type? Query __type with the type's name, then select the metadata needed from the returned __Type value.

QWhat is the difference between __schema and __typename?

__typename is a meta-field that returns the concrete object type at the current response location. It can be selected for Object, Interface, and Union types, while __schema describes the schema itself.

Follow-up: Why is __typename useful with abstract types? It lets clients identify the concrete runtime type and choose the matching fragment.

QWhy is introspection useful beyond manual exploration?

Introspection queries are special queries for learning about an API's schema, including its types, fields, and descriptions. This metadata also helps power GraphQL development tools.

Follow-up: What tooling can schema metadata support? It can drive documentation and client or development-tool behavior without separately maintained type descriptions.

  • __schema
  • __type
  • __typename
  • __Schema
  • __Type

Source: Introspection. Checked 2026-10-15.