Skip to content

Commit 905b424

Browse files
committed
Updated ingredients/schema.py and recipes/schema.py to be more readable.
1 parent 4359e1f commit 905b424

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

examples/cookbook-plain/cookbook/ingredients/schema.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,14 @@ class Query(object):
2525
name=graphene.String())
2626
all_ingredients = graphene.List(IngredientType)
2727

28-
def resolve_all_categories(self, context, **kwargs):
28+
def resolve_all_categories(self, context):
2929
return Category.objects.all()
3030

31-
def resolve_all_ingredients(self, context, **kwargs):
31+
def resolve_all_ingredients(self, context):
3232
# We can easily optimize query count in the resolve method
3333
return Ingredient.objects.select_related('category').all()
3434

35-
def resolve_category(self, context, **kwargs):
36-
id = kwargs.get('id')
37-
name = kwargs.get('name')
38-
35+
def resolve_category(self, context, id=None, name=None):
3936
if id is not None:
4037
return Category.objects.get(pk=id)
4138

@@ -44,10 +41,7 @@ def resolve_category(self, context, **kwargs):
4441

4542
return None
4643

47-
def resolve_ingredient(self, context, **kwargs):
48-
id = kwargs.get('id')
49-
name = kwargs.get('name')
50-
44+
def resolve_ingredient(self, context, id=None, name=None):
5145
if id is not None:
5246
return Ingredient.objects.get(pk=id)
5347

examples/cookbook-plain/cookbook/recipes/schema.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ class Query(object):
2424
id=graphene.Int())
2525
all_recipeingredients = graphene.List(RecipeIngredientType)
2626

27-
def resolve_recipe(self, context, **kwargs):
28-
id = kwargs.get('id')
29-
title = kwargs.get('title')
30-
27+
def resolve_recipe(self, context, id=None, title=None):
3128
if id is not None:
3229
return Recipe.objects.get(pk=id)
3330

@@ -36,17 +33,15 @@ def resolve_recipe(self, context, **kwargs):
3633

3734
return None
3835

39-
def resolve_recipeingredient(self, context, **kwargs):
40-
id = kwargs.get('id')
41-
36+
def resolve_recipeingredient(self, context, id=None):
4237
if id is not None:
4338
return RecipeIngredient.objects.get(pk=id)
4439

4540
return None
4641

47-
def resolve_all_recipes(self, context, **kwargs):
42+
def resolve_all_recipes(self, context):
4843
return Recipe.objects.all()
4944

50-
def resolve_all_recipeingredients(self, context, **kwargs):
45+
def resolve_all_recipeingredients(self, context):
5146
related = ['recipe', 'ingredient']
5247
return RecipeIngredient.objects.select_related(*related).all()

0 commit comments

Comments
 (0)