From a556ab89f4ef293ad29f6834514131b9599e287c Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Sun, 29 Nov 2015 23:03:14 -0800 Subject: [PATCH] Exclude flake8 syntax in docs. Added tea_store example --- docs/playground/examples/tea_store.graphql | 8 +++++ docs/playground/examples/tea_store.schema.py | 38 ++++++++++++++++++++ setup.cfg | 2 +- 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 docs/playground/examples/tea_store.graphql create mode 100644 docs/playground/examples/tea_store.schema.py diff --git a/docs/playground/examples/tea_store.graphql b/docs/playground/examples/tea_store.graphql new file mode 100644 index 00000000..8cafaae0 --- /dev/null +++ b/docs/playground/examples/tea_store.graphql @@ -0,0 +1,8 @@ +query { + store { + teas(orderBy:"name") { + name + steepingTime + } + } +} diff --git a/docs/playground/examples/tea_store.schema.py b/docs/playground/examples/tea_store.schema.py new file mode 100644 index 00000000..60caafcf --- /dev/null +++ b/docs/playground/examples/tea_store.schema.py @@ -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) \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 21db934b..d9e6b06f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [flake8] -exclude = setup.py +exclude = setup.py,docs/* max-line-length = 120 [coverage:run]