--- id: graphene-django-optimizer version: "0.10.0" license: MIT license_treatment: permissive maintenance: dormant --- # graphene-django-optimizer — Optimize database access inside graphene queries. License: permissive · Maintenance: dormant · Downloads: 143.5K/mo ## What it is and what it does graphene-django-optimizer wraps Django QuerySet queries to automatically apply select_related, prefetch_related, and only optimizations based on the GraphQL query structure. It inspects the incoming GraphQL request and modifies the underlying database query to fetch only the fields and relationships actually requested, eliminating N+1 query problems that commonly plague GraphQL-to-ORM integrations. The package integrates directly into graphene-django resolvers via a gql_optimizer.query() wrapper and provides decorators for custom resolvers that need explicit optimization hints. It supports both simple auto-optimized fields and advanced cases where resolvers use filtering or custom logic, allowing developers to declare which relationships and fields should be prefetched or selected. Use it for: - Reduce database queries when fetching nested relationships in GraphQL queries with select_related and prefetch_related. - Optimize single-node queries using OptimizedDjangoObjectType to automatically apply select_related and only to individual object resolvers. - Handle filtered prefetch scenarios where a resolver argument determines which related objects to load. - Prevent N+1 query problems in production GraphQL APIs backed by Django ORM without manual queryset tuning per resolver. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Automatically optimizes GraphQL queries executed by graphene-django using Django QuerySet methods like select_related, prefetch_related, and only to reduce database round-trips. Yes, if you are actively using graphene-django with Django 2.2 or 3.1 and Python 3.6, 3.7, or 3.8. The package solves a real performance problem (N+1 queries) with minimal friction. However, be aware that maintenance is dormant—last release was 2023-08-05—so compatibility with newer Django or graphene versions is unverified. Evaluate whether your stack's versions align with the classifiers before committing. ## Install pip install graphene-django-optimizer uv add graphene-django-optimizer poetry add graphene-django-optimizer ## Installing graphene-django-optimizer Before you install: Low friction installation with no runtime dependencies. Maintenance is dormant—last release was 2023-08-05, over a year ago, though the repository remains active with 437 stars and not archived. License in practice: MIT license permits unrestricted commercial and private use, modification, and distribution with minimal obligations beyond attribution. Quickstart: pip install graphene-django-optimizer import graphene_django_optimizer as gql_optimizer class Query(graphene.ObjectType): all_items = graphene.List(ItemType) def resolve_all_items(root, info): return gql_optimizer.query(Item.objects.all(), info) Requires graphene-django to be installed and a Django project with ORM models; version 0.10.0 targets Graphene V3 (use version 0.8 for Graphene V2). Verify before relying: - Whether the package is compatible with current versions of graphene-django and Django beyond those listed in classifiers - Whether dormant maintenance status indicates the package is stable or at risk of incompatibility with future Django/graphene releases - Whether version 0.10.0 works with Graphene V3 as intended or if compatibility issues exist ## Package facts - License: MIT (permissive) - Python support: unspecified - Install friction: low - Maintenance: dormant - Downloads: 143.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags graphql query optimization django, graphene-django performance, reduce n+1 queries graphql, django select_related prefetch_related, graphene query optimizer, django graphql database optimization, graphql, orm-optimization, django [View on SkillFed](https://skillfed.io/packages/graphene-django-optimizer) · [View on PyPI](https://pypi.org/project/graphene-django-optimizer/)