GraphQL Introspection

A key feature of GraphQL that gives a lot of benefits over REST is Introspection. The GraphQL query language is strongly typed. This strong type system gives the ability to query and understand the underlying schema.

The schema acts as the contract between the frontend and backend teams. But how does the frontend developer know what the backend schema looks like? How do they prevent over-fetching or under-fetching? This is possible due to Introspection queries.

Introspection Queries

A GraphQL server supports introspection over its schema using the same GraphQL query language.

A server exposes the following introspection queries on the Query operation type.

  • __schema
  • __type
  • __typename

Note that introspection queries start with __.

Community Tooling

The ability to introspect is what allows the community to build awesome tooling around GraphQL. There's GraphiQL and GraphQL Playground which leverages the Introspection feature to provide self-documentation to developers and try out APIs quickly.

The above tools use the __schema introspection query to give the documentation of the schema. You can explore more by trying out the __schema query to see the different selection set, fields, and directives.


Get Started with GraphQL Now

Hasura Cloud gives you a fully managed, production ready GraphQL API as a service to help you build modern apps faster.
Ready to get started?
Start for free on Hasura Cloud or you could contact our sales team for a detailed walk-through on how Hasura may benefit your business.
Stay in the know
Sign up for full access to our community highlights, new features, and occasional baby animal gifs! Oh, and we have a strict no-spam rule. ✌️