GraphQL - Schema Introspection

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

Management

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"
      },
      ....
  ]
  }
}

Built-in type

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

Documentation / Reference


Powered by ComboStrap