Skip to content

Commit 9308e6d

Browse files
committed
Merge pull request #75 from lightning18/dump-schema
Add Django graphql_schema command documentation
2 parents 062c0f9 + 25022f5 commit 9308e6d

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
title: Introspection Schema
3+
description: A guide to instrospection schema in Django
4+
---
5+
6+
# Introspection Schema
7+
8+
Relay uses [Babel Relay Plugin](https://facebook.github.io/relay/docs/guides-babel-plugin.html)
9+
that requires you to provide your GraphQL schema data.
10+
11+
Graphene comes with a management command for Django to dump your schema data to
12+
`schema.json` that is compatible with babel-relay-plugin.
13+
14+
15+
## Usage
16+
17+
Include `graphene.django.contrib` to `INSTALLED_APPS` in you project settings:
18+
19+
```python
20+
INSTALLED_APPS += ('graphene.django.contrib')
21+
```
22+
23+
Assuming your Graphene schema is at `tutorial.quickstart.schema`, run the command:
24+
25+
```bash
26+
./manage.py graphql_schema --schema tutorial.quickstart.schema --out schema.json
27+
```
28+
29+
It dumps your full introspection schema to `schema.json` inside your project root
30+
directory. Point `babel-relay-plugin` to this file and you're ready to use Relay
31+
with Graphene GraphQL implementation.
32+
33+
34+
## Advanced Usage
35+
36+
To simplify the command to `./manage.py graphql_schema`, you can specify the
37+
parameters in your settings.py:
38+
39+
```python
40+
GRAPHENE_SCHEMA = 'tutorial.quickstart.schema'
41+
GRAPHENE_SCHEMA_OUTPUT = 'data/schema.json' # defaults to schema.json
42+
```
43+
44+
Running `./manage.py graphql_schema` dumps your schema to
45+
`<project root>/data/schema.json`.
46+
47+
48+
## Help
49+
50+
Run `./manage.py graphql_schema -h` for command usage.

0 commit comments

Comments
 (0)