django-graphex Documentation¶
django-graphex builds on graphene and Pydantic to make Django GraphQL APIs easy, without Relay:
- Allow pagination and filtering on Queries
- Allow defining Pydantic-backed Mutations directly from Django models
- Allow using Directives on Queries and Fragments
- Optional GraphQL Subscriptions over Django Channels 4
Subscription Support
GraphQL subscriptions now live here as the optional
django-graphex[subscriptions] extra (built on Django Channels 4).
The standalone
graphene-django-subscriptions
package is now a deprecated compatibility shim that re-exports from here.
Key Features¶
🔍 Fields¶
- DjangoObjectField - Single object queries with automatic ID filtering
- DjangoFilterListField - List queries with filtering
- DjangoFilterPaginateListField - List queries with filtering and pagination
- DjangoListObjectField - :material-star: Recommended for Queries
🧬 Types¶
- DjangoListObjectType - :material-star: Recommended for Types
- DjangoInputObjectType - Input types for mutations
- DjangoModelType - :material-star: Recommended for quick setup
⚡ Mutations¶
- DjangoModelMutation - :material-star: Recommended for Mutations
📄 Pagination¶
- LimitOffsetGraphqlPagination - Offset-based pagination
- PageGraphqlPagination - Page-based pagination
- CursorGraphqlPagination - Keyset (cursor) pagination with
pageInfo
🎯 Directives¶
- String formatting - Case transformation, encoding, manipulation
- Number formatting - Currency, mathematical operations
- Date formatting - Custom date formats with python-dateutil
- List operations - Shuffle, sample operations
Quick Example¶
Basic Usage
from django_graphex import (
DjangoListObjectType,
DjangoModelMutation,
LimitOffsetGraphqlPagination
)
class UserListType(DjangoListObjectType):
class Meta:
model = User
pagination = LimitOffsetGraphqlPagination(default_limit=25)
class UserMutation(DjangoModelMutation):
class Meta:
model = User
Getting Started¶
Ready to dive in? Check out our Installation Guide to get started, or jump straight to the Quick Start for a hands-on tutorial.
Community & Support¶
- GitHub Issues: Report bugs or request features
- PyPI Package: Install from PyPI
- Source Code: View on GitHub