Here's your chance to speak at GraphQL Summit in New York City, October 8 - 10, 2024! 🏙️ Submit your proposal by May 31.
Docs
Launch GraphOS Studio
You're viewing documentation for a previous version of this software. Switch to the latest stable version.

Downloading a schema


requires a file as input to its code generation process. You can provide your schema either as a JSON file (most commonly the result of an ) or as a .graphqls file that uses syntax. Conventionally, this file is named schema.json or schema.graphqls (depending on its format), and you store it in the same folder as your project's App:

Location of schema file in project

📣 Check it out: Instead of writing the scripts below in Bash, try using our new Swift Scripting Library, now in Beta! It supports downloading a schema and generating code.

You can use the Apollo CLI to download a GraphQL schema by sending an introspection query to the server. If you've installed the CLI globally, you can use the following command to download your schema:

apollo schema:download --endpoint=http://localhost:8080/graphql schema.json

Note that if you're using the local version set up for codegen, you should use the same method you're using in the Add a code generation build step instructions to access that specific CLI. For example, if you're using CocoaPods, you can set it up like this to download your schema:

SCRIPT_PATH="${PODS_ROOT}/Apollo/scripts"
cd "${SRCROOT}/${TARGET_NAME}"
"${SCRIPT_PATH}"/run-bundled-codegen.sh schema:download --endpoint=http://localhost:8080/graphql schema.json

If needed, you can use the header option to add additional HTTP headers to the request. For example, to include an authentication token, use --header "Authorization: Bearer <token>":

[your apollo version] schema:download --endpoint=http://localhost:8080/graphql --header="Authorization: Bearer <token>"
Previous
9. Write your first subscription
Next
Creating a client
Edit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy

Company