Downloading a schema

Apollo iOS requires a GraphQL schema file as input to the code generation process. A schema file is a JSON file that contains the results of an introspection query. Conventionally this file is called schema.json, and you store it next to the .graphql files in your target.

You can use apollo from the apollo-cli package 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'll want to use the same method you're using in the Adding 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}"/check-and-run-apollo-cli.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>"
Edit on GitHub