Join us from October 8-10 in New York City to learn the latest tips, trends, and news about GraphQL federation and API platform engineering.Join us for GraphQL Summit 2024 in NYC
Docs
Start for Free

Downloading a schema


requires a file as input to its code generation process. You can provide your schema either in JSON format (most commonly the result of an ) or in GraphQL ().

Conventionally, JSON files have the .json extension and SDL files use the .graphqls extension.

There are a few ways to download a GraphQL schema:

1. Apollo Studio

Apollo Studio is a cloud platform that helps you build, validate, and secure your organization's .

In the SDL view of the Schema tab of Apollo Studio there is a drop-down menu where you can download the linked schema in SDL or JSON format.

Below is a screenshot showing the StarWars GraphQL API in an Apollo Studio public example. On the right-hand side you can see the drop-down allowing downloads of both formats.

Where to download a schema from Apollo Studio

Please see the documentation for further details on how to use Apollo Studio.

2. Codegen CLI

The Codegen CLI provides a convenient command-line tool for fetching a GraphQL schema and writing it to a file.

See the documentation on the fetch-schema command for details on how to use it.

The codegen CLI also supports fetching a GraphQL schema as an initial step in the code generation process. This automates fetching the schema and ensures you are always using the most up-to-date schema.

See the documentation on the generate command for details on how to use it.

The Apollo schema registry and introspection are both supported as methods for downloading.

Apollo schema registry

The Apollo schema registry serves as a central hub for managing your graph. At its core, the schema registry is a version control system for schemas. It stores a schema's change history, tracking the types and that were added, modified, and removed. In order to fetch a schema from the schema registry using the codegen CLI you will need credentials detailed in Schema download configuration.

GraphQL introspection

GraphQL introspection enables you to query a for information about the underlying schema. This includes data like types, fields, queries, , and even the field-level descriptions.

See the GraphQL spec for full details on the introspection feature.

Note: Many production servers disable introspection for security reasons. If your introspection query is failing check that it is not disabled.

Previous
Configuration
Next
Running Code Generation in Swift Code
Rate articleRateEdit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy

Company