__type query in introspection
If we just want to retrieve about the specific object or other types , then we can follow the below way using __type query. It helps in retrieving the schema related to the __type query only. Here, it will look only for __type query and ignore other metadata such as mutations etc.,
For Example, if we want to query about the specific object then we will have to pass the name of the object to __type query.
Input:
The below input query will fetch the details of the Student Object.
__type ( name : "Student")
{
name
kind
}
Output:
{
"data" : {
"__type" : {
"name" : "Student"
"kind" : "Object" //type of Student
}
}
}
Explanation: It fetches the schema of Student Object from API. Here, it shows the name of the object and kind of the Student.
Introspection in GraphQL
Introspection in GraphQL is a powerful feature that allows users to understand and query the structure of a GraphQL schema. It enables developers to dynamically explore the available object types, mutations, queries, and fields supported by the server.
Introspection plays a crucial role in GraphQL development, providing valuable insights into the schema’s composition and facilitating tools like GraphQL IDEs to offer enhanced features such as autocomplete suggestions and schema browsing. In this article, We will learn about Introspection in GraphQL along with its working and types.