...

/

Introduction to Schema Introspection

Introduction to Schema Introspection

Learn about GraphQL schema introspection.

yIt’s important to check which queries or operations a GraphQL server supports. To accommodate this functionality, GraphQL has an introspection system.

When we’ve designed the type system ourselves, we know which types are available. However, if we haven’t designed it, we could ask GraphQL by querying the __schema. The field is always open on the root type of a query. Let’s ask GraphQL what types are available:

Press + to interact
{
__schema {
types {
name
}
}
}

Using the query above, we’ll get the following response:

Press + to interact
{
"data": {
"__schema": {
"types": [
{
"name": "PizzaStatus"
},
{
"name": "Pizza"
},
{
"name": "Int"
},
{
"name": "String"
},
{
"name": "Topping"
},
{
"name": "ToppingInput"
},
{
"name": "Query"
},
{
"name": "Mutation"
},
{
"name": "Boolean"
},
{
"name": "__Schema"
},
{
"name": "__Type"
},
{
"name": "__TypeKind"
},
{
"name": "__Field"
},
{
"name": "__InputValue"
},
{
"name": "__EnumValue"
},
{
"name": "__Directive"
},
{
"name": "__DirectiveLocation"
}
]
}
}
}

Wow, that’s a lot of types! What are they? Let’s put them into groups.

  • Query, Mutation, Pizza, PizzaStatus, Topping, and ToppingInput: These are the ones that we defined in our type system.

  • Int, ...