Improved quick start page

This commit is contained in:
Syrus Akbary 2015-10-08 01:48:54 -07:00
parent 9a84945232
commit 8b1a3d0409

View File

@ -33,9 +33,36 @@ pip install graphene
## Types
First we're going to define some GraphQL ObjectTypes that we'll use in our `Schema`:
First we're going to define some GraphQL ObjectTypes for our `Schema`:
```
```python
import graphene
```
schema = graphene.Schema()
# This will be our root query
class Query(graphene.ObjectType):
username = graphene.StringField(description='The username')
def resolve_username(self, *args):
return 'Hello World'
# Here we set the root query for our schema
schema.query = Query
```
Then, we can start querying our schema:
```python
result = schema.execute('{ username }')
# result.data should be {'username': 'Hello World'}
username = result.data['username']
print(username)
```
Congrats! You got your first version of graphene working!
**This Quickstart page needs to be improved, meanwhile visit the [schema](https://github.com/graphql-python/django-graphene-example/blob/master/starwars/schema.py) of our Starwars Django example!**