Introspection
GraphQL allows clients to ask a server for information about its schema. GraphQL calls this introspection.
We can ask GraphQL for this information by querying the __schema
meta-field, which is always available on the root type of a Query per the spec.
1 | query { |
Example:1
2
3
4
5
6
7
8
9
10
11type Query {
author(id: ID!): Author
}
type Author {
posts: [Post!]!
}
type Post {
title: String!
}
If we were to send the introspection query mentioned above, we would get the following result:
1 | { |
If we query a single type with __type
:
1 | { |
We’ll get:
1 | { |