Skip to content

MrThearMan/graphene-django-query-optimizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f13e9fc · Feb 23, 2024
Feb 23, 2024
Feb 22, 2024
Feb 23, 2024
Feb 22, 2024
Aug 19, 2023
Aug 19, 2023
Aug 19, 2023
Feb 20, 2024
Aug 19, 2023
Aug 19, 2023
Feb 21, 2024
Oct 7, 2023
Aug 19, 2023
Feb 22, 2024
Feb 21, 2024
Feb 23, 2024

Repository files navigation

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 just by changing a few imports, automatically adding 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 DjangoListField
from example import ExampleModel

# from graphene_django import DjangoObjectType  # old import
from query_optimizer import DjangoObjectType  # new import

class ExampleType(DjangoObjectType):
    class Meta:
        model = ExampleModel

class Query(graphene.ObjectType):
    all_examples = DjangoListField(ExampleType)

schema = graphene.Schema(query=Query)