Automatically optimize SQL queries in Graphene-Django schemas.
Project description
Graphene Django Query Optimizer
pip install graphene-django-query-optimizer
Documentation: https://mrthearman.github.io/graphene-django-query-optimizer/
Source Code: https://github.com/MrThearMan/graphene-django-query-optimizer/
Contributing: https://github.com/MrThearMan/graphene-django-query-optimizer/blob/main/CONTRIBUTING.md
Solve the GraphQL N+1 problem in graphene-django applications with a single function
(plus a few classes that call it) that adds the appropriate
only
,
select_related
,
and prefetch_related
method calls to your QuerySets to fetch only what you need.
import graphene
# from graphene_django import DjangoObjectType # old imports
from query_optimizer import DjangoObjectType, optimize # new imports
from example import ExampleModel
class ExampleType(DjangoObjectType):
class Meta:
model = ExampleModel
class Query(graphene.ObjectType):
all_examples = graphene.List(ExampleType)
def resolve_examples(root, info):
return optimize(ExampleModel.objects.all(), info) # Optimized!
schema = graphene.Schema(query=Query)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for graphene_django_query_optimizer-0.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b0f3db46a7ae54f64a63d272d2eaa5ad18dc420d23f6555230fddffc0b0eddd |
|
MD5 | d546295e54b8d4b6102faf501e3776fb |
|
BLAKE2b-256 | e830c774df13ded93086239046d298b20a4e1a426a311698300eb384d3e3d353 |
Close
Hashes for graphene_django_query_optimizer-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3d81414c9f9229ffafe52fed7b9707e9137f1bf410fcad7f4c590216b858baa |
|
MD5 | 09d5ae8711d8c46df46758565ca25ccb |
|
BLAKE2b-256 | cf4be9701bb7e591a4691f6e2e9f4636d294fa19f03e4b699a44bd2576603d95 |