-
Notifications
You must be signed in to change notification settings - Fork 769
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* π§ Add pre-commit config Similar to graphene and graphene-sqlalchemy * β¬ Bump black * π· Lint on CI * β¬ Bump flake8-black * π§ Keep excluding migrations * β¬ Bump flake8 * π§ Remove black and flake8 from tox config * β¬ Update pre-commit versions * Upgrade syntax to python 3.7+ * Format with pre-commit dedent docs/schema.py to allow formatting * Fix tests on python 3.7
- Loading branch information
Showing
59 changed files
with
779 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
default_language_version: | ||
python: python3.9 | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.0 | ||
hooks: | ||
- id: check-merge-conflict | ||
- id: check-json | ||
- id: check-yaml | ||
- id: debug-statements | ||
- id: end-of-file-fixer | ||
exclude: ^docs/.*$ | ||
- id: pretty-format-json | ||
args: | ||
- --autofix | ||
- id: trailing-whitespace | ||
exclude: README.md | ||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v2.37.3 | ||
hooks: | ||
- id: pyupgrade | ||
args: [--py37-plus] | ||
- repo: https://github.com/psf/black | ||
rev: 22.6.0 | ||
hooks: | ||
- id: black | ||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 5.0.4 | ||
hooks: | ||
- id: flake8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,4 +59,4 @@ Then to produce a HTML version of the documentation: | |
|
||
```sh | ||
make html | ||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,57 @@ | ||
import graphene | ||
import graphene | ||
|
||
from graphene_django.types import DjangoObjectType | ||
from graphene_django.types import DjangoObjectType | ||
|
||
from cookbook.ingredients.models import Category, Ingredient | ||
from cookbook.ingredients.models import Category, Ingredient | ||
|
||
|
||
class CategoryType(DjangoObjectType): | ||
class Meta: | ||
model = Category | ||
fields = '__all__' | ||
class CategoryType(DjangoObjectType): | ||
class Meta: | ||
model = Category | ||
fields = "__all__" | ||
|
||
|
||
class IngredientType(DjangoObjectType): | ||
class Meta: | ||
model = Ingredient | ||
fields = '__all__' | ||
class IngredientType(DjangoObjectType): | ||
class Meta: | ||
model = Ingredient | ||
fields = "__all__" | ||
|
||
|
||
class Query(object): | ||
category = graphene.Field(CategoryType, | ||
id=graphene.Int(), | ||
name=graphene.String()) | ||
all_categories = graphene.List(CategoryType) | ||
class Query: | ||
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() | ||
) | ||
all_ingredients = graphene.List(IngredientType) | ||
|
||
ingredient = graphene.Field(IngredientType, | ||
id=graphene.Int(), | ||
name=graphene.String()) | ||
all_ingredients = graphene.List(IngredientType) | ||
def resolve_all_categories(self, info, **kwargs): | ||
return Category.objects.all() | ||
|
||
def resolve_all_categories(self, info, **kwargs): | ||
return Category.objects.all() | ||
def resolve_all_ingredients(self, info, **kwargs): | ||
return Ingredient.objects.all() | ||
|
||
def resolve_all_ingredients(self, info, **kwargs): | ||
return Ingredient.objects.all() | ||
def resolve_category(self, info, **kwargs): | ||
id = kwargs.get("id") | ||
name = kwargs.get("name") | ||
|
||
def resolve_category(self, info, **kwargs): | ||
id = kwargs.get('id') | ||
name = kwargs.get('name') | ||
if id is not None: | ||
return Category.objects.get(pk=id) | ||
|
||
if id is not None: | ||
return Category.objects.get(pk=id) | ||
if name is not None: | ||
return Category.objects.get(name=name) | ||
|
||
if name is not None: | ||
return Category.objects.get(name=name) | ||
return None | ||
|
||
return None | ||
def resolve_ingredient(self, info, **kwargs): | ||
id = kwargs.get("id") | ||
name = kwargs.get("name") | ||
|
||
def resolve_ingredient(self, info, **kwargs): | ||
id = kwargs.get('id') | ||
name = kwargs.get('name') | ||
if id is not None: | ||
return Ingredient.objects.get(pk=id) | ||
|
||
if id is not None: | ||
return Ingredient.objects.get(pk=id) | ||
if name is not None: | ||
return Ingredient.objects.get(name=name) | ||
|
||
if name is not None: | ||
return Ingredient.objects.get(name=name) | ||
|
||
return None | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 52 additions & 1 deletion
53
examples/cookbook-plain/cookbook/ingredients/fixtures/ingredients.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,52 @@ | ||
[{"model": "ingredients.category", "pk": 1, "fields": {"name": "Dairy"}}, {"model": "ingredients.category", "pk": 2, "fields": {"name": "Meat"}}, {"model": "ingredients.ingredient", "pk": 1, "fields": {"name": "Eggs", "notes": "Good old eggs", "category": 1}}, {"model": "ingredients.ingredient", "pk": 2, "fields": {"name": "Milk", "notes": "Comes from a cow", "category": 1}}, {"model": "ingredients.ingredient", "pk": 3, "fields": {"name": "Beef", "notes": "Much like milk, this comes from a cow", "category": 2}}, {"model": "ingredients.ingredient", "pk": 4, "fields": {"name": "Chicken", "notes": "Definitely doesn't come from a cow", "category": 2}}] | ||
[ | ||
{ | ||
"fields": { | ||
"name": "Dairy" | ||
}, | ||
"model": "ingredients.category", | ||
"pk": 1 | ||
}, | ||
{ | ||
"fields": { | ||
"name": "Meat" | ||
}, | ||
"model": "ingredients.category", | ||
"pk": 2 | ||
}, | ||
{ | ||
"fields": { | ||
"category": 1, | ||
"name": "Eggs", | ||
"notes": "Good old eggs" | ||
}, | ||
"model": "ingredients.ingredient", | ||
"pk": 1 | ||
}, | ||
{ | ||
"fields": { | ||
"category": 1, | ||
"name": "Milk", | ||
"notes": "Comes from a cow" | ||
}, | ||
"model": "ingredients.ingredient", | ||
"pk": 2 | ||
}, | ||
{ | ||
"fields": { | ||
"category": 2, | ||
"name": "Beef", | ||
"notes": "Much like milk, this comes from a cow" | ||
}, | ||
"model": "ingredients.ingredient", | ||
"pk": 3 | ||
}, | ||
{ | ||
"fields": { | ||
"category": 2, | ||
"name": "Chicken", | ||
"notes": "Definitely doesn't come from a cow" | ||
}, | ||
"model": "ingredients.ingredient", | ||
"pk": 4 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
examples/cookbook-plain/cookbook/ingredients/migrations/0002_auto_20161104_0050.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9 on 2016-11-04 00:50 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('ingredients', '0001_initial'), | ||
("ingredients", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='ingredient', | ||
name='notes', | ||
model_name="ingredient", | ||
name="notes", | ||
field=models.TextField(blank=True, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.