Introspection Schema

Relay uses Babel Relay Plugin that requires you to provide your GraphQL schema data.

Graphene comes with a management command for Django to dump your schema data to schema.json that is compatible with babel-relay-plugin.


Include graphene_django to INSTALLED_APPS in you project settings:

INSTALLED_APPS += ('graphene_django')

Assuming your Graphene schema is at tutorial.quickstart.schema, run the command:

./ graphql_schema --schema tutorial.quickstart.schema --out schema.json

It dumps your full introspection schema to schema.json inside your project root directory. Point babel-relay-plugin to this file and you’re ready to use Relay with Graphene GraphQL implementation.

Advanced Usage

The --indent option can be used to specify the number of indentation spaces to be used in the output. Defaults to None which displays all data on a single line.

To simplify the command to ./ graphql_schema, you can specify the parameters in your

    'SCHEMA': 'tutorial.quickstart.schema',
    'SCHEMA_OUTPUT': 'data/schema.json'  # defaults to schema.json

Running ./ graphql_schema dumps your schema to <project root>/data/schema.json.


Run ./ graphql_schema -h for command usage.