GraphQL - Schema Introspection

1 - About

Schema Introspection (ie querying the schema and not the data)

Example: graphql/graphql-js/blob/master/src/__tests__/starWarsIntrospection-test.js

The introspection file in GraphQL.js contains code implementing a specification-compliant GraphQL query introspection system

3 - Management

3.1 - See

We can ask GraphQL, by querying the __schema field, always available on the root type of a Query.

Example:


query IntrospectionTypeQuery {
  __schema {
    types {
      name
    }
  }
}

and we get all the types with the name field.


{
  "__schema": {
    "types": [
      {
        "name": "Query"
      },
      {
        "name": "Character"
      },
      {
        "name": "Human"
      },
      ....
  ]
  }
}

3.2 - Built-in type

  • __Schema, __Type, __TypeKind, __Field, __InputValue, __EnumValue, __Directive preceded with a double underscore, indicating that they are part of the introspection system.

4 - Documentation / Reference


Data Science
Data Analysis
Statistics
Data Science
Linear Algebra Mathematics
Trigonometry

Powered by ComboStrap