Skip to content

Commit cdde833

Browse files
committed
Merge branch 'docs' of github.com:graphql-python/graphene into docs
Conflicts: docs/pages/docs/quickstart-django.md
2 parents 944d361 + abc4c91 commit cdde833

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

docs/pages/docs/quickstart-django.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: A Quick guide to Graphene in Django
77

88
In our previous quickstart page we created a very simple schema.
99

10-
Now we will adapt the schema to map automatically some Django models,
10+
Now we will adapt the schema to automatically map some Django models,
1111
and expose this schema in a `/graphql` API endpoint.
1212

1313
## Project setup
@@ -49,17 +49,25 @@ Once you've set up a database and initial user created and ready to go, open up
4949

5050
## Schema
5151

52-
Right, we'd better write some types then. Open `quickstart/schema.py` and get typing.
52+
GraphQL presents your objects to the world as a graph structure rather than a more
53+
heiricarcal structure to which you may be acustomed. In order to create this
54+
representation, Graphene needs to know about each *type* of object which will appear in
55+
the graph. Below we define these as the `UserType` and `GroupType` classes.
56+
57+
This graph also has a 'root' through which all access begins. This is the `Query` class below.
58+
In this example, we provide the ability to list all users via `all_users`, and the
59+
ability to obtain a single user via `get_user`.
60+
61+
Open `tutorial/quickstart/schema.py` and type the following:
5362

5463
```python
5564
import graphene
5665
from graphene.contrib.django import DjangoObjectType
5766

5867
from django.contrib.auth.models import User, Group
5968

60-
61-
# Graphene will map automatically the User model to UserType with
62-
# the specified fields
69+
# Graphene will automatically map the User model's fields onto the UserType.
70+
# This is configured in the UserType's Meta class
6371
class UserType(DjangoObjectType):
6472
class Meta:
6573
model = User
@@ -105,8 +113,12 @@ INSTALLED_APPS = [
105113

106114
## Creating GraphQL and GraphiQL views
107115

108-
Okay, now let's wire up the GraphQL and GraphiQL urls. On to `tutorial/urls.py`...
116+
Unlike a RESTful API, there is only a single URL from which a GraphQL is accessed.
117+
Requests to this URL are handled by Graphene's `GraphQLView` view.
109118

119+
Additionally, and interface for navigating this API will be very useful. Graphene
120+
includes the [graphiql](https://github.com/graphql/graphiql) in-browser IDE
121+
which assits and exploring and querying your new API. We'll add a URL for this too.
110122

111123
```python
112124
from django.conf.urls import url, include
@@ -115,7 +127,7 @@ from graphene.contrib.django.views import GraphQLView
115127
from quickstart.schema import schema
116128

117129

118-
# Wire up our GraphQL schema in /graphql.
130+
# Wire up our GraphQL schema to /graphql.
119131
# Additionally, we include GraphiQL view for querying easily our schema.
120132
urlpatterns = [
121133
url(r'^graphql', csrf_exempt(GraphQLView.as_view(schema=schema))),

0 commit comments

Comments
 (0)