Skip to main content

Automatically optimize SQL queries in Graphene-Django schemas.

Project description

Graphene Django Query Optimizer

Coverage Status GitHub Workflow Status PyPI GitHub GitHub Last Commit GitHub Issues Downloads Python Version

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

graphene_django_query_optimizer-0.0.6.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file graphene_django_query_optimizer-0.0.6.tar.gz.

File metadata

File hashes

Hashes for graphene_django_query_optimizer-0.0.6.tar.gz
Algorithm Hash digest
SHA256 40adce85c8f8a8eb67189e55c2717e88c1565e3870c903951db552ce1816b282
MD5 2dca0b849d07205c3fd37d641a106f83
BLAKE2b-256 ce4f5406afeabb3aeb3ab9bca19415583790de4debd676ed2989810e2d8506af

See more details on using hashes here.

File details

Details for the file graphene_django_query_optimizer-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for graphene_django_query_optimizer-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 db9715135848bfbc6de1c7d1aa69030a5d17068f55c8ebf73072121e3df64a1d
MD5 c2e8b61c75f98b1984a9deddebc09279
BLAKE2b-256 49527c09123465f31ce8aa98b5f467cc5aa3df77200eeceb79c6fdd77e2f7427

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page