Skip to main content
Version: 5.x.x

Introspection

By default, GraphQL servers expose a built-in system, called introspection, that exposes details about the underlying schema. Clients can use introspection to obtain information about all the supported queries as well as all the types exposed in the schema.

Introspection types#

  • __schema - root level query field that provides information about all entry points (e.g. queryType), all types exposed by the schema (including built-in scalars and introspection types) as well as all directives supported by the system
  • __type(name: String!) - root level query field that provides information about the requested type (if it exists)
  • typename - field that can be added to ANY selection and will return the name of the enclosing type, is often used in polymorphic queries in order to easily determine underlying implementation type
  • Directive, DirectiveLocation, EnumValue, Field, InputValue, Schema, Type, TypeKind - built-in introspection types that are used to describe the schema.

For example, the query below will return a root Query object name as well as names of all types and all directives.

query {  __schema {    queryType {      name    }    types {      name    }    directives {      name    }  }}

Additional information on introspection can be found on GraphQL.org.

Disabling Introspection#

Introspection system can be disabled by specifying introspectionEnabled=false configuration option on an instance of SchemaGeneratorConfig that will be used by the SchemaGenerator to generate the GraphQL schema.

Many GraphQL tools (e.g. GraphQL Playground or GraphiQL) rely on introspection queries to function properly. Disabling introspection will prevent clients from accessing __schema and __type fields. This may break some of the functionality that your clients might rely on and should be used with extreme caution.