Skip to content

Commit

Permalink
Prettify md files, ignore asdf file
Browse files Browse the repository at this point in the history
  • Loading branch information
tfoxy committed Aug 5, 2023
1 parent 618f819 commit bbf5fc4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
venv/
venv2/
venv3/
venv*/
*.pyc
.vscode/
.idea/
*.egg-info/
.eggs/
.pytest_cache/
.tool-versions
dist/
build/
.coverage
Expand Down
7 changes: 2 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -64,8 +61,8 @@ Fetching all the ingredients with the related category:
id
name
category {
id
name
id
name
}
}
}
Expand All @@ -88,8 +85,8 @@ Fetching all the categories with the related ingredients:
id
name
ingredients {
id
name
id
name
}
}
}
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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)

Expand All @@ -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)

0 comments on commit bbf5fc4

Please sign in to comment.