From bbf5fc4b501a0d7d1f3239059c38ab2e82c8f4c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Fox?= Date: Sat, 5 Aug 2023 14:36:37 -0300 Subject: [PATCH] Prettify md files, ignore asdf file --- .gitignore | 5 ++--- CONTRIBUTING.md | 7 ++----- README.md | 21 ++++++++++----------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 7c8edbc..1144fd2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,11 @@ -venv/ -venv2/ -venv3/ +venv*/ *.pyc .vscode/ .idea/ *.egg-info/ .eggs/ .pytest_cache/ +.tool-versions dist/ build/ .coverage diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0158b4d..cd433a6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,22 +1,19 @@ # Contributing - ## Environment The system must have installed: -* python 3 -* virtualenv +- python 3 ```sh -virtualenv -p python3 venv +python -m venv venv . venv/bin/activate pip install -r dev-requirements.txt # run tests: python setup.py test ``` - ## Publish ```sh diff --git a/README.md b/README.md index 0d9361c..d1f718f 100644 --- a/README.md +++ b/README.md @@ -8,15 +8,13 @@ Optimize queries executed by [graphene-django](https://github.com/graphql-python/graphene-django) automatically, using [`select_related`](https://docs.djangoproject.com/en/2.0/ref/models/querysets/#select-related), [`prefetch_related`](https://docs.djangoproject.com/en/2.0/ref/models/querysets/#prefetch-related) and [`only`](https://docs.djangoproject.com/en/2.0/ref/models/querysets/#only) methods of Django QuerySet. - - ## Install ```bash pip install graphene-django-optimizer ``` -*Note: If you are using Graphene V2, please install version `0.8`. v0.9 and forward will support only Graphene V3* +_Note: If you are using Graphene V2, please install version `0.8`. v0.9 and forward will support only Graphene V3_ ## Usage @@ -53,7 +51,6 @@ class Query(graphene.ObjectType): return gql_optimizer.query(Ingredient.objects.all(), info) ``` - We will show some graphql queries and the queryset that will be executed. Fetching all the ingredients with the related category: @@ -64,8 +61,8 @@ Fetching all the ingredients with the related category: id name category { - id - name + id + name } } } @@ -88,8 +85,8 @@ Fetching all the categories with the related ingredients: id name ingredients { - id - name + id + name } } } @@ -107,7 +104,6 @@ categories = ( ) ``` - ## Advanced usage Sometimes we need to have a custom resolver function. In those cases, the field can't be auto optimized. @@ -185,7 +181,6 @@ class CartType(gql_optimizer.OptimizedDjangoObjectType): With these hints, any field can be optimized. - ### Optimize with non model fields Sometimes we need to have a custom non model fields. In those cases, the optimizer would not optimize with the Django `.only()` method. @@ -198,7 +193,7 @@ class IngredientType(gql_optimizer.OptimizedDjangoObjectType): class Meta: model = Ingredient - + def resolve_calculated_calories(root, info): return get_calories_for_ingredient(root.id) @@ -209,3 +204,7 @@ class Query(object): def resolve_all_ingredients(root, info): return gql_optimizer.query(Ingredient.objects.all(), info, disable_abort_only=True) ``` + +## Contributing + +See [CONTRIBUTING.md](./CONTRIBUTING.md)