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.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40adce85c8f8a8eb67189e55c2717e88c1565e3870c903951db552ce1816b282 |
|
MD5 | 2dca0b849d07205c3fd37d641a106f83 |
|
BLAKE2b-256 | ce4f5406afeabb3aeb3ab9bca19415583790de4debd676ed2989810e2d8506af |
Close
Hashes for graphene_django_query_optimizer-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db9715135848bfbc6de1c7d1aa69030a5d17068f55c8ebf73072121e3df64a1d |
|
MD5 | c2e8b61c75f98b1984a9deddebc09279 |
|
BLAKE2b-256 | 49527c09123465f31ce8aa98b5f467cc5aa3df77200eeceb79c6fdd77e2f7427 |