Exclude flake8 syntax in docs. Added tea_store example

This commit is contained in:
Syrus Akbary 2015-11-29 23:03:14 -08:00
parent 18b66bd8a2
commit a556ab89f4
3 changed files with 47 additions and 1 deletions

View File

@ -0,0 +1,8 @@
query {
store {
teas(orderBy:"name") {
name
steepingTime
}
}
}

View File

@ -0,0 +1,38 @@
import graphene
class Tea(graphene.ObjectType):
name = graphene.String()
steeping_time = graphene.Int()
TEAS = [
Tea(name='Earl Grey Blue Star', steeping_time=5),
Tea(name='Milk Oolong', steeping_time=3),
Tea(name='Gunpowder Golden Temple', steeping_time=3),
Tea(name='Assam Hatimara', steeping_time=5),
Tea(name='Bancha', steeping_time=2),
Tea(name='Ceylon New Vithanakande', steeping_time=5),
Tea(name='Golden Tip Yunnan', steeping_time=5),
Tea(name='Jasmine Phoenix Pearls', steeping_time=3),
Tea(name='Kenya Milima', steeping_time=5),
Tea(name='Pu Erh First Grade', steeping_time=4),
Tea(name='Sencha Makoto', steeping_time=3),
]
class Store(graphene.ObjectType):
teas = graphene.List(Tea, order_by=graphene.String())
def resolve_teas(self, args, info):
order_by = args.get("order_by")
if order_by == "steepingTime":
return sorted(self.teas, key=lambda tea: tea.steeping_time)
elif order_by == "name":
return sorted(self.teas, key=lambda tea: tea.name)
return self.teas
class Query(graphene.ObjectType):
store = graphene.Field(Store)
def resolve_store(self, args, info):
return Store(teas=TEAS)
schema = graphene.Schema(query=Query)

View File

@ -1,5 +1,5 @@
[flake8]
exclude = setup.py
exclude = setup.py,docs/*
max-line-length = 120
[coverage:run]