Enabling Introspection
There are three ways to enable introspection in your schema:Introspection Fields
When introspection is enabled, two special fields are added to your schema’s query type:__schema
Returns information about the entire schema.
__Schema! (non-null)
Implementation: The field is added in lib/rails/graphql/introspection.rb:34-36:
__type
Looks up a specific type by name.
name(String!, required) - The name of the type to find
__Type (nullable)
Implementation: The field is added in lib/rails/graphql/introspection.rb:38-41:
Introspection Types
The following special types are available when introspection is enabled:__Schema
Describes the schema’s structure.
All types known to the schema
The object containing query fields
The object containing mutation fields
The object containing subscription fields
All directives known to the schema
__Type
Describes any type (enums, inputs, interfaces, objects, scalars, unions).
The category of this type
The GraphQL name of this type
The documentation string
Output fields (objects and interfaces only)
Implemented interfaces (objects only)
Possible implementations (interfaces and unions only)
Available values (enums only)
Input fields (input objects only)
The underlying wrapped type (for lists and non-nulls)
__Field
Describes an output field on an object or interface.
The GraphQL name
The documentation string
Arguments accepted by the field
The return type
Whether the field is deprecated
Deprecation reason, if any
__InputValue
Describes an argument or input field.
The GraphQL name
The documentation string
The accepted type
Default value as a JSON string
__EnumValue
Describes a value within an enum.
The GraphQL name
The documentation string
Whether the value is deprecated
Deprecation reason, if any
__Directive
Describes a directive.
The GraphQL name
The documentation string
Valid locations for this directive
Arguments accepted by the directive
Whether the directive can be used multiple times
Introspection Enums
__TypeKind
Enumerates the fundamental GraphQL type categories.
__DirectiveLocation
Enumerates valid directive placement locations.
Implementation Details
Introspection is implemented in theRails::GraphQL::Introspection module (lib/rails/graphql/introspection.rb:6):
lib/rails/graphql/type/ when introspection is enabled.
You can get the schema structure using the
to_gql output from your controller’s describe action. See the controller customization guide for details.