< back to main page
< back to main page
Results for query IntrospectionQuery{__schema{queryType{name} types{name}}}
The query IntrospectionQuery{__schema{queryType{name} types{name}}} is a GraphQL introspection query that retrieves two main pieces of information from a GraphQL API's schema:
- The name of the root query type (typically called "Query", but it can have a custom name)51.
- A list of all types defined in the schema, with each type's name123.
Context and Details:
- The
__schemafield is used for introspection to expose metadata about the entire schema, such as available types, entry points for queries, mutations, and subscriptions51. - The
queryType { name }part returns the name of the root type for queries—in most APIs, this is "Query", but custom names are possible54. - The
types { name }part returns a list of all defined type names in the schema, which can include scalars (like Int, String), objects (like Student, Teacher), interfaces, enums, and introspection types (like Type, Field)13.
Sample Input and Output (Simplified):
Input:
query IntrospectionQuery {
__schema {
queryType { name }
types { name }
}
}
Sample Output:
{
"data": {
"__schema": {
"queryType": { "name": "Query" },
"types": [
{ "name": "Int" },
{ "name": "String" },
{ "name": "Student" },
{ "name": "Teacher" },
{ "name": "__Type" },
{ "name": "__Field" }
]
}
}
}
(Exact types will vary by API, but this demonstrates typical content.)12
Purpose and Use:
- This query is used by developer tools (like GraphiQL or Apollo Studio) and clients to explore and document the API, generate type-safe queries, or automate client code531.
- Introspection is often enabled by default, but for security reasons can sometimes be disabled in production environments413.
Related Concepts:
- You can extend introspection queries to also return information about mutations (
mutationType), subscriptions (subscriptionType), field definitions, arguments, and directives for a comprehensive schema map236.
This query is a standard starting point for understanding what a GraphQL API can do and how to interact with it programmatically52.