Skip to content

Commit a556ab8

Browse files
committed
Exclude flake8 syntax in docs. Added tea_store example
1 parent 18b66bd commit a556ab8

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
query {
2+
store {
3+
teas(orderBy:"name") {
4+
name
5+
steepingTime
6+
}
7+
}
8+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import graphene
2+
3+
class Tea(graphene.ObjectType):
4+
name = graphene.String()
5+
steeping_time = graphene.Int()
6+
7+
TEAS = [
8+
Tea(name='Earl Grey Blue Star', steeping_time=5),
9+
Tea(name='Milk Oolong', steeping_time=3),
10+
Tea(name='Gunpowder Golden Temple', steeping_time=3),
11+
Tea(name='Assam Hatimara', steeping_time=5),
12+
Tea(name='Bancha', steeping_time=2),
13+
Tea(name='Ceylon New Vithanakande', steeping_time=5),
14+
Tea(name='Golden Tip Yunnan', steeping_time=5),
15+
Tea(name='Jasmine Phoenix Pearls', steeping_time=3),
16+
Tea(name='Kenya Milima', steeping_time=5),
17+
Tea(name='Pu Erh First Grade', steeping_time=4),
18+
Tea(name='Sencha Makoto', steeping_time=3),
19+
]
20+
21+
class Store(graphene.ObjectType):
22+
teas = graphene.List(Tea, order_by=graphene.String())
23+
24+
def resolve_teas(self, args, info):
25+
order_by = args.get("order_by")
26+
if order_by == "steepingTime":
27+
return sorted(self.teas, key=lambda tea: tea.steeping_time)
28+
elif order_by == "name":
29+
return sorted(self.teas, key=lambda tea: tea.name)
30+
return self.teas
31+
32+
class Query(graphene.ObjectType):
33+
store = graphene.Field(Store)
34+
35+
def resolve_store(self, args, info):
36+
return Store(teas=TEAS)
37+
38+
schema = graphene.Schema(query=Query)

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[flake8]
2-
exclude = setup.py
2+
exclude = setup.py,docs/*
33
max-line-length = 120
44

55
[coverage:run]

0 commit comments

Comments
 (0)