How can I get list of all types from graphql schema?

Viewed 5350

On client I get schema by introspectSchema.

In my app I want to get list of all types which we have in schema, but parse existing object is very hard task.

Is there some good way to do it?

1 Answers

GraphQL has powerful introspection capabilities built in. To get the names of the types in your schema you can run this GraphQL query:

{
  __schema {
    types {
      name
    }
  }
}

You can read more about introspection in GraphQL here:

https://graphql.org/learn/introspection/

Related