Skip to content

GraphQL to Schema AST Converter — Numio

Parses GraphQL SDL, builds a schema and prints it back as a single normalized schema with @graphql-codegen/schema-ast. Type extensions are merged into their base types and descriptions are printed as block strings.

Merging extend type blocks spread across several files into one schema.graphql for review or tooling.

GraphQL Schema

Schema AST

When to use it

  • Merging extend type blocks spread across several files into one schema.graphql for review or tooling.
  • Normalizing hand-written SDL into the canonical printed format before diffing two schema versions.

How to use

  1. Paste one or more SDL fragments, including any extend type blocks, into the GraphQL Schema editor.
  2. Check the printed result: extension fields are added to the original type and descriptions become """ blocks.
  3. Copy the output and save it as a .graphql file.

GraphQL schema

extend type Query {
  me: User
}

type Query {
  ping: String
}

type User {
  id: ID!
  "Display name"
  name: String @deprecated(reason: "Use fullName")
}

Printed schema (SDL)

type Query {
  me: User
  ping: String
}

type User {
  id: ID!

  """
  Display name
  """
  name: String @deprecated(reason: "Use fullName")
}

Details and limitations

Field order can change: fields from an extend type block were printed before the base type's own fields in this example.

Field directives such as @deprecated(reason: ...) are kept in the printed SDL.

The schema is built and printed in a Web Worker in your browser, then formatted with Prettier's GraphQL parser.

FAQ

Does it output a JSON AST?

No. Despite the name, the result is printed GraphQL SDL, not a JSON DocumentNode. Use the introspection JSON page if you need JSON.

What happens to # comments?

Comments are not part of the schema and are dropped when the schema is printed. Use "description" strings to keep documentation.

Can it merge extend type into the base type?

Yes. Extensions are applied to the base type, so the output contains a single type Query with all fields.

Specifications and references