__typename Query in Introspection
The __typename is used to return the name of the object that is being queried. If we mention the __typename in any of the query response then it will display the object type of that particular response. It will help the developers to know what object type is being used for the response.
Example:
The below input has __typename inside query. The __typename will fetch the object or interface or others name that’s being queried.
Input:
query {
user(login: xyz)
{
__typename
}
Output:
"data" : {
"user" : {
__typename : "Student"
}
}
The above input query has queried using the Student object.
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.