mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-23 01:57:08 +03:00
Update tutorial-plain.rst
This commit is contained in:
parent
283bccf9d3
commit
7400179a34
|
@ -80,7 +80,7 @@ Add ingredients as INSTALLED_APPS:
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
...
|
...
|
||||||
# Install the ingredients app
|
# Install the ingredients app
|
||||||
'ingredients',
|
'cookbook.ingredients',
|
||||||
]
|
]
|
||||||
|
|
||||||
Don't forget to create & run migrations:
|
Don't forget to create & run migrations:
|
||||||
|
@ -157,10 +157,10 @@ Create ``cookbook/ingredients/schema.py`` and type the following:
|
||||||
all_categories = graphene.List(CategoryType)
|
all_categories = graphene.List(CategoryType)
|
||||||
all_ingredients = graphene.List(IngredientType)
|
all_ingredients = graphene.List(IngredientType)
|
||||||
|
|
||||||
def resolve_all_categories(self, info, **kwargs):
|
def resolve_all_categories(self, args, context, info):
|
||||||
return Category.objects.all()
|
return Category.objects.all()
|
||||||
|
|
||||||
def resolve_all_ingredients(self, info, **kwargs):
|
def resolve_all_ingredients(self, args, context, info):
|
||||||
# We can easily optimize query count in the resolve method
|
# We can easily optimize query count in the resolve method
|
||||||
return Ingredient.objects.select_related('category').all()
|
return Ingredient.objects.select_related('category').all()
|
||||||
|
|
||||||
|
@ -438,15 +438,15 @@ We can update our schema to support that, by adding new query for ``ingredient``
|
||||||
name=graphene.String())
|
name=graphene.String())
|
||||||
all_ingredients = graphene.List(IngredientType)
|
all_ingredients = graphene.List(IngredientType)
|
||||||
|
|
||||||
def resolve_all_categories(self, info, **kwargs):
|
def resolve_all_categories(self, args, context, info):
|
||||||
return Category.objects.all()
|
return Category.objects.all()
|
||||||
|
|
||||||
def resolve_all_ingredients(self, info, **kwargs):
|
def resolve_all_ingredients(self, args, context, info):
|
||||||
return Ingredient.objects.all()
|
return Ingredient.objects.all()
|
||||||
|
|
||||||
def resolve_category(self, info, **kwargs):
|
def resolve_category(self, args, context, info):
|
||||||
id = kargs.get('id')
|
id = args.get('id')
|
||||||
name = kargs.get('name')
|
name = args.get('name')
|
||||||
|
|
||||||
if id is not None:
|
if id is not None:
|
||||||
return Category.objects.get(pk=id)
|
return Category.objects.get(pk=id)
|
||||||
|
@ -456,9 +456,9 @@ We can update our schema to support that, by adding new query for ``ingredient``
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def resolve_ingredient(self, info, **kwargs):
|
def resolve_ingredient(self, args, context, info):
|
||||||
id = kargs.get('id')
|
id = args.get('id')
|
||||||
name = kargs.get('name')
|
name = args.get('name')
|
||||||
|
|
||||||
if id is not None:
|
if id is not None:
|
||||||
return Ingredient.objects.get(pk=id)
|
return Ingredient.objects.get(pk=id)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user