Skip to content

Commit

Permalink
Merge 4275aba into 44e9b0d
Browse files Browse the repository at this point in the history
  • Loading branch information
jkimbo committed Jun 11, 2019
2 parents 44e9b0d + 4275aba commit 70a90f7
Show file tree
Hide file tree
Showing 43 changed files with 328 additions and 436 deletions.
74 changes: 37 additions & 37 deletions .travis.yml
@@ -1,58 +1,58 @@
language: python
sudo: required
cache: pip
dist: xenial

python:
- 2.7
- 3.4
- 3.5
- 3.6
- 3.7

env:
matrix:
- DJANGO=1.11
- DJANGO=2.1
- DJANGO=2.2
- DJANGO=master

install:
- TOX_ENV=py${TRAVIS_PYTHON_VERSION}-django${DJANGO}
- pip install tox
- tox -e $TOX_ENV --notest
script:
- tox -e $TOX_ENV
- pip install tox tox-travis

after_success:
- tox -e $TOX_ENV -- pip install coveralls
- tox -e $TOX_ENV -- coveralls $COVERALLS_OPTION
script:
- tox

after_success:
- pip install coveralls
- coveralls

matrix:
fast_finish: true
include:
- python: 3.5
script: tox -e lint
exclude:
- python: 2.7
env: DJANGO=1.11

- python: 3.5
env: DJANGO=1.11
- python: 3.5
env: DJANGO=2.0
- python: 3.5
env: DJANGO=2.1
- python: 2.7
- python: 3.5
env: DJANGO=2.2
- python: 2.7
env: DJANGO=master
- python: 3.4

- python: 3.6
env: DJANGO=1.11
- python: 3.6
env: DJANGO=2.0
- python: 3.6
env: DJANGO=2.1
- python: 3.4
- python: 3.6
env: DJANGO=2.2
- python: 3.4
- python: 3.6
env: DJANGO=master
- python: 3.5
env: DJANGO=master
- python: 3.7
env: DJANGO=1.10

- python: 3.7
env: DJANGO=1.11
allow_failures:
- python: 3.7
env: DJANGO=2.0
- python: 3.7
env: DJANGO=2.1
- python: 3.7
env: DJANGO=2.2
- python: 3.7
env: DJANGO=master

- python: 3.7
env: TOXENV=black,flake8

allow_failures:
- env: DJANGO=master

deploy:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -5,7 +5,7 @@ tests:
py.test graphene_django --cov=graphene_django -vv

format:
black graphene_django
black --exclude "/migrations/" graphene_django examples

lint:
flake8 graphene_django
flake8 graphene_django examples
4 changes: 2 additions & 2 deletions examples/cookbook-plain/cookbook/ingredients/admin.py
Expand Up @@ -5,8 +5,8 @@

@admin.register(Ingredient)
class IngredientAdmin(admin.ModelAdmin):
list_display = ('id', 'name', 'category')
list_editable = ('name', 'category')
list_display = ("id", "name", "category")
list_editable = ("name", "category")


admin.site.register(Category)
6 changes: 3 additions & 3 deletions examples/cookbook-plain/cookbook/ingredients/apps.py
Expand Up @@ -2,6 +2,6 @@


class IngredientsConfig(AppConfig):
name = 'cookbook.ingredients'
label = 'ingredients'
verbose_name = 'Ingredients'
name = "cookbook.ingredients"
label = "ingredients"
verbose_name = "Ingredients"
7 changes: 5 additions & 2 deletions examples/cookbook-plain/cookbook/ingredients/models.py
Expand Up @@ -3,7 +3,8 @@

class Category(models.Model):
class Meta:
verbose_name_plural = 'Categories'
verbose_name_plural = "Categories"

name = models.CharField(max_length=100)

def __str__(self):
Expand All @@ -13,7 +14,9 @@ def __str__(self):
class Ingredient(models.Model):
name = models.CharField(max_length=100)
notes = models.TextField(null=True, blank=True)
category = models.ForeignKey(Category, related_name='ingredients', on_delete=models.CASCADE)
category = models.ForeignKey(
Category, related_name="ingredients", on_delete=models.CASCADE
)

def __str__(self):
return self.name
12 changes: 5 additions & 7 deletions examples/cookbook-plain/cookbook/ingredients/schema.py
Expand Up @@ -15,22 +15,20 @@ class Meta:


class Query(object):
category = graphene.Field(CategoryType,
id=graphene.Int(),
name=graphene.String())
category = graphene.Field(CategoryType, id=graphene.Int(), name=graphene.String())
all_categories = graphene.List(CategoryType)

ingredient = graphene.Field(IngredientType,
id=graphene.Int(),
name=graphene.String())
ingredient = graphene.Field(
IngredientType, id=graphene.Int(), name=graphene.String()
)
all_ingredients = graphene.List(IngredientType)

def resolve_all_categories(self, context):
return Category.objects.all()

def resolve_all_ingredients(self, context):
# We can easily optimize query count in the resolve method
return Ingredient.objects.select_related('category').all()
return Ingredient.objects.select_related("category").all()

def resolve_category(self, context, id=None, name=None):
if id is not None:
Expand Down
1 change: 0 additions & 1 deletion examples/cookbook-plain/cookbook/ingredients/tests.py
@@ -1,2 +1 @@

# Create your tests here.
1 change: 0 additions & 1 deletion examples/cookbook-plain/cookbook/ingredients/views.py
@@ -1,2 +1 @@

# Create your views here.
6 changes: 3 additions & 3 deletions examples/cookbook-plain/cookbook/recipes/apps.py
Expand Up @@ -2,6 +2,6 @@


class RecipesConfig(AppConfig):
name = 'cookbook.recipes'
label = 'recipes'
verbose_name = 'Recipes'
name = "cookbook.recipes"
label = "recipes"
verbose_name = "Recipes"
22 changes: 14 additions & 8 deletions examples/cookbook-plain/cookbook/recipes/models.py
Expand Up @@ -6,17 +6,23 @@
class Recipe(models.Model):
title = models.CharField(max_length=100)
instructions = models.TextField()

def __str__(self):
return self.title


class RecipeIngredient(models.Model):
recipe = models.ForeignKey(Recipe, related_name='amounts', on_delete=models.CASCADE)
ingredient = models.ForeignKey(Ingredient, related_name='used_by', on_delete=models.CASCADE)
recipe = models.ForeignKey(Recipe, related_name="amounts", on_delete=models.CASCADE)
ingredient = models.ForeignKey(
Ingredient, related_name="used_by", on_delete=models.CASCADE
)
amount = models.FloatField()
unit = models.CharField(max_length=20, choices=(
('unit', 'Units'),
('kg', 'Kilograms'),
('l', 'Litres'),
('st', 'Shots'),
))
unit = models.CharField(
max_length=20,
choices=(
("unit", "Units"),
("kg", "Kilograms"),
("l", "Litres"),
("st", "Shots"),
),
)
9 changes: 3 additions & 6 deletions examples/cookbook-plain/cookbook/recipes/schema.py
Expand Up @@ -15,13 +15,10 @@ class Meta:


class Query(object):
recipe = graphene.Field(RecipeType,
id=graphene.Int(),
title=graphene.String())
recipe = graphene.Field(RecipeType, id=graphene.Int(), title=graphene.String())
all_recipes = graphene.List(RecipeType)

recipeingredient = graphene.Field(RecipeIngredientType,
id=graphene.Int())
recipeingredient = graphene.Field(RecipeIngredientType, id=graphene.Int())
all_recipeingredients = graphene.List(RecipeIngredientType)

def resolve_recipe(self, context, id=None, title=None):
Expand All @@ -43,5 +40,5 @@ def resolve_all_recipes(self, context):
return Recipe.objects.all()

def resolve_all_recipeingredients(self, context):
related = ['recipe', 'ingredient']
related = ["recipe", "ingredient"]
return RecipeIngredient.objects.select_related(*related).all()
1 change: 0 additions & 1 deletion examples/cookbook-plain/cookbook/recipes/tests.py
@@ -1,2 +1 @@

# Create your tests here.
1 change: 0 additions & 1 deletion examples/cookbook-plain/cookbook/recipes/views.py
@@ -1,2 +1 @@

# Create your views here.
10 changes: 6 additions & 4 deletions examples/cookbook-plain/cookbook/schema.py
Expand Up @@ -5,10 +5,12 @@
from graphene_django.debug import DjangoDebug


class Query(cookbook.ingredients.schema.Query,
cookbook.recipes.schema.Query,
graphene.ObjectType):
debug = graphene.Field(DjangoDebug, name='_debug')
class Query(
cookbook.ingredients.schema.Query,
cookbook.recipes.schema.Query,
graphene.ObjectType,
):
debug = graphene.Field(DjangoDebug, name="_debug")


schema = graphene.Schema(query=Query)

0 comments on commit 70a90f7

Please sign in to comment.