This project has been archived by its maintainers, and is no longer receiving any updates.
Graphene-Django-Extras
This package adds some extra functionalities to graphene-django to facilitate the graphql use without Relay:
Allow pagination and filtering on Queries
Allow defining DjangoRestFramework serializers based on Mutations.
Allow using Directives on Queries and Fragments.
NOTE: Subscription support was moved to graphene-django-subscriptions
Requirements
Python: 3.12+ (3.13 and 3.14 supported)
Django: 4.0+ (4.2, 5.0, 5.1, 5.2, and 6.0 supported)
Graphene-Django: 3.2+
Quick Start
Installation
pip install graphene-django-extras
Basic Usage
from graphene_django_extras import DjangoListObjectType, DjangoSerializerMutation
class UserListType(DjangoListObjectType):
class Meta:
model = User
class UserMutation(DjangoSerializerMutation):
class Meta:
serializer_class = UserSerializer
Documentation
📚 Full Documentation: https://eamigo86.github.io/graphene-django-extras/
The complete documentation includes:
Installation Guide - Getting started
Quick Start - Basic setup and examples
Usage Guide - Detailed feature documentation
Directives - GraphQL directives for data formatting
API Reference - Complete API documentation
Changelog - Version history
Key Features
🔍 Fields
DjangoObjectField
DjangoFilterListField
DjangoFilterPaginateListField
DjangoListObjectField (Recommended)
🧬 Types
DjangoListObjectType (Recommended)
DjangoInputObjectType
DjangoSerializerType (Recommended)
⚡ Mutations
DjangoSerializerMutation (Recommended)
📄 Pagination
LimitOffsetGraphqlPagination
PageGraphqlPagination
🎯 Directives
String formatting (case, encoding, manipulation)
Number formatting (currency, math operations)
Date formatting (with python-dateutil)
List operations (shuffle, sample)
Configuration
You can configure global parameters for DjangoListObjectType classes in your settings.py:
GRAPHENE_DJANGO_EXTRAS = {
'DEFAULT_PAGINATION_CLASS': 'graphene_django_extras.paginations.LimitOffsetGraphqlPagination',
'DEFAULT_PAGE_SIZE': 20,
'MAX_PAGE_SIZE': 50,
'CACHE_ACTIVE': True,
'CACHE_TIMEOUT': 300 # seconds
}
Examples
Types Definition
from django.contrib.auth.models import User
from graphene_django_extras import DjangoListObjectType, DjangoSerializerType
from graphene_django_extras.paginations import LimitOffsetGraphqlPagination
class UserListType(DjangoListObjectType):
class Meta:
model = User
pagination = LimitOffsetGraphqlPagination()
filter_fields = {
"id": ("exact",),
"username": ("icontains", "iexact"),
"email": ("icontains", "iexact"),
}
Mutations Definition
from graphene_django_extras import DjangoSerializerMutation
from .serializers import UserSerializer
class UserMutation(DjangoSerializerMutation):
class Meta:
serializer_class = UserSerializer
Schema Definition
import graphene
from graphene_django_extras import DjangoObjectField, DjangoListObjectField
class Query(graphene.ObjectType):
users = DjangoListObjectField(UserListType)
user = DjangoObjectField(UserType)
class Mutation(graphene.ObjectType):
user_create = UserMutation.CreateField()
user_update = UserMutation.UpdateField()
user_delete = UserMutation.DeleteField()
schema = graphene.Schema(query=Query, mutation=Mutation)
Directives
Configure directives in your settings.py:
GRAPHENE = {
'MIDDLEWARE': [
'graphene_django_extras.ExtraGraphQLDirectiveMiddleware'
]
}
Usage example:
from graphene_django_extras import all_directives
schema = graphene.Schema(
query=Query,
mutation=Mutation,
directives=all_directives
)
Development
See our Development Guide for contributing guidelines.
License
MIT License - see LICENSE file for details.
Metadata
Release files for graphene-django-extras 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| graphene_django_extras-1.1.0.tar.gz | 36.2 kB | Without provenance | Details for graphene_django_extras-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| graphene_django_extras-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for graphene_django_extras-1.1.0-py3-none-any.whl |
Total release size: 80.9 kB
Release files / graphene_django_extras-1.1.0.tar.gz
| Download URL | graphene_django_extras-1.1.0.tar.gz |
|---|---|
| Size | 36.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a35f598dec4406b426bdbae409034d1dd1d15605c9ffe61252fc29c62291519f
|
|
BLAKE2b-256 checksum How to use checksums |
31facd812a9751f03640f22db6d1ad6cc15d9562da4ad9edc5a3a868f5f67bb5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.12.12 Linux/6.11.0-1018-azure
|
Release files / graphene_django_extras-1.1.0-py3-none-any.whl
| Download URL | graphene_django_extras-1.1.0-py3-none-any.whl |
|---|---|
| Size | 44.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
37315bbcb9f8d5181032fceb0586f1c97479bf8cf2ce00008d729f86c0ce3e07
|
|
BLAKE2b-256 checksum How to use checksums |
13c8d2514030726f850572ac1123a7b1a62770e00f0e97e0146b638cf29d1ed2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.12.12 Linux/6.11.0-1018-azure
|
Security for graphene-django-extras 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.