From 8b1a3d0409f6b608abb88c0b8578b9b38be0f4b5 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 8 Oct 2015 01:48:54 -0700 Subject: [PATCH] Improved quick start page --- quickstart.md | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/quickstart.md b/quickstart.md index f9b0f7a1..d74c7151 100644 --- a/quickstart.md +++ b/quickstart.md @@ -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 -``` \ No newline at end of file +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!**