rail-django-graphql


Namerail-django-graphql JSON
Version 1.1.3 PyPI version JSON
download
home_pagehttps://github.com/raillogistic/rail-django-graphql
SummaryA powerful Django library for automatic GraphQL API generation with advanced features
upload_time2025-10-14 20:52:29
maintainerNone
docs_urlNone
authorRail Logistic
requires_python>=3.8
licenseMIT
keywords django graphql api graphene schema generator rail automation
VCS
bugtrack_url
requirements Django graphene graphene-django django-filter graphene-file-upload django-cors-headers
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Rail Django GraphQL

[![CI](https://github.com/raillogistic/rail-django-graphql/workflows/CI/badge.svg)](https://github.com/raillogistic/rail-django-graphql/actions)
[![PyPI version](https://badge.fury.io/py/rail-django-graphql.svg)](https://badge.fury.io/py/rail-django-graphql)
[![Python versions](https://img.shields.io/pypi/pyversions/rail-django-graphql.svg)](https://pypi.org/project/rail-django-graphql/)
[![Django versions](https://img.shields.io/pypi/djversions/rail-django-graphql.svg)](https://pypi.org/project/rail-django-graphql/)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

A powerful Django library for automatic GraphQL schema generation with advanced features including type generation, query optimization, permissions, and comprehensive debugging tools.

## Features

- 🚀 **Automatic Schema Generation**: Generate GraphQL schemas from Django models with zero configuration
- 🔧 **Type Generators**: Automatic GraphQL type creation with customizable field mappings
- 🔍 **Query Optimization**: Built-in query optimization and N+1 problem prevention
- 🛡️ **Advanced Permissions**: Flexible permission system with field-level access control
- 🐛 **Debugging Tools**: Comprehensive debugging and introspection capabilities
- 📊 **Performance Monitoring**: Built-in performance metrics and query analysis
- 🔌 **Plugin System**: Extensible architecture with custom plugins
- 🎨 **GraphiQL Integration**: Enhanced GraphiQL interface with custom tools
- 📝 **Auto Documentation**: Automatic API documentation generation
- 🔒 **Security Features**: Built-in security measures and validation

## Installation

### From PyPI (Recommended)

```bash
pip install rail-django-graphql
```

### From GitHub (Development Version)

```bash
# Install directly from GitHub
pip install git+https://github.com/raillogistic/rail-django-graphql.git

# Or clone and install locally
git clone https://github.com/raillogistic/rail-django-graphql.git
cd rail-django-graphql
pip install -e .
```

### Optional Dependencies

Install additional features:

```bash
# Authentication support
pip install rail-django-graphql[auth]

# Performance optimizations
pip install rail-django-graphql[performance]

# Media handling
pip install rail-django-graphql[media]

# Monitoring and metrics
pip install rail-django-graphql[monitoring]

# All optional features
pip install rail-django-graphql[all]
```

## Quick Start

### 1. Add to Django Settings

```python
# settings.py
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    
    # GraphQL dependencies
    'graphene_django',
    'django_filters',
    'corsheaders',
    
    # Rail Django GraphQL
    'rail_django_graphql',
    
    # Your apps
    'your_app',
]

# GraphQL Configuration
GRAPHENE = {
    'SCHEMA': 'your_project.schema.schema',
    'MIDDLEWARE': [
        'rail_django_graphql.middleware.QueryOptimizationMiddleware',
        'rail_django_graphql.middleware.PermissionMiddleware',
        'rail_django_graphql.middleware.DebuggingMiddleware',
    ],
}

# Rail Django GraphQL Settings
RAIL_GRAPHQL = {
    'AUTO_GENERATE_SCHEMA': True,
    'ENABLE_DEBUGGING': True,
    'ENABLE_INTROSPECTION': True,
    'MAX_QUERY_DEPTH': 10,
    'ENABLE_QUERY_OPTIMIZATION': True,
}
```

### 2. Create Your Schema

```python
# schema.py
import graphene
from rail_django_graphql import (
    TypeGenerator,
    QueryGenerator,
    MutationGenerator,
    SchemaBuilder
)
from your_app.models import User, Post, Comment

# Generate types automatically
UserType = TypeGenerator.from_model(User)
PostType = TypeGenerator.from_model(Post)
CommentType = TypeGenerator.from_model(Comment)

# Generate queries
class Query(graphene.ObjectType):
    # Auto-generated queries
    users = QueryGenerator.list_field(User)
    user = QueryGenerator.detail_field(User)
    posts = QueryGenerator.list_field(Post)
    post = QueryGenerator.detail_field(Post)
    
    # Custom queries
    my_posts = graphene.List(PostType)
    
    def resolve_my_posts(self, info):
        return Post.objects.filter(author=info.context.user)

# Generate mutations
class Mutation(graphene.ObjectType):
    create_post = MutationGenerator.create_mutation(Post)
    update_post = MutationGenerator.update_mutation(Post)
    delete_post = MutationGenerator.delete_mutation(Post)

# Build schema
schema = SchemaBuilder.build(
    query=Query,
    mutation=Mutation,
    auto_discover=True  # Automatically discover and include all models
)
```

### 3. Add URLs

```python
# urls.py
from django.contrib import admin
from django.urls import path, include
from graphene_django.views import GraphQLView
from rail_django_graphql.views.graphql_views import (
    MultiSchemaGraphQLView,
    SchemaListView,
    GraphQLPlaygroundView,
)
from rail_django_graphql.health_urls import health_urlpatterns

urlpatterns = [
    path('admin/', admin.site.urls),
    # Single schema endpoint (backward compatible)
    path('graphql/', GraphQLView.as_view(graphiql=True)),
    # Multi-schema endpoints
    path('graphql/<str:schema_name>/', MultiSchemaGraphQLView.as_view(), name='graphql-by-schema'),
    path('schemas/', SchemaListView.as_view(), name='graphql-schemas'),
    path('playground/<str:schema_name>/', GraphQLPlaygroundView.as_view(), name='graphql-playground'),
    # Health endpoints
    path('health/', include(health_urlpatterns)),
]
```

### 4. Run Migrations and Start Server

```bash
python manage.py migrate
python manage.py runserver
```

Visit `http://localhost:8000/graphql/` to access the GraphiQL interface.

## Advanced Usage
### Multi-Schema Setup

The library supports multiple schemas with per-schema settings, endpoints, and GraphiQL control.

1) Enable multi-schema in settings and register schemas via the registry:

```python
# settings.py
RAIL_DJANGO_GRAPHQL = {
    "MULTI_SCHEMA_ENABLED": True,
}

# myapp/schema_config.py
from rail_django_graphql.core.registry import schema_registry

schema_registry.register_schema(
    name="public_api",
    description="Public API for customers",
    version="1.0.0",
    apps=["customers", "products"],
    models=["Customer", "Product"],
    enabled=True,
    settings={
        "enable_graphiql": True,
        "authentication_required": False,
    },
)

schema_registry.register_schema(
    name="admin_api",
    description="Admin API for internal use",
    version="1.0.0",
    apps=["customers", "products", "orders"],
    models=["Customer", "Product", "Order", "User"],
    enabled=True,
    settings={
        "enable_graphiql": True,
        "authentication_required": True,
    },
)
```

2) Configure URLs to expose per-schema endpoints:

```python
from django.urls import path
from rail_django_graphql.views.graphql_views import MultiSchemaGraphQLView, SchemaListView, GraphQLPlaygroundView

urlpatterns = [
    path('graphql/<str:schema_name>/', MultiSchemaGraphQLView.as_view(), name='graphql-by-schema'),
    path('schemas/', SchemaListView.as_view(), name='graphql-schemas'),
    path('playground/<str:schema_name>/', GraphQLPlaygroundView.as_view(), name='graphql-playground'),
]
```

Endpoints provided:
- `GET/POST /graphql/<schema_name>/` — Execute queries against the specified schema
- `GET /schemas/` — List registered schemas and their metadata
- `GET /playground/<schema_name>/` — Open a schema-specific GraphQL Playground

3) Control per-schema authentication and GraphiQL:

```python
schema_registry.register_schema(
    name="secure_api",
    enabled=True,
    settings={
        "authentication_required": True,
        "permission_classes": ["django.contrib.auth.permissions.IsAuthenticated"],
        "enable_graphiql": False,  # Disable GraphiQL for production
    },
)
```

See more details in `rail_django_graphql/views/graphql_views.py` and the integration tests in `rail_django_graphql/tests/integration/test_multi_schema.py`.

### Custom Type Generation

```python
from rail_django_graphql import TypeGenerator
from your_app.models import User

# Basic type generation
UserType = TypeGenerator.from_model(User)

# Advanced type generation with custom fields
UserType = TypeGenerator.from_model(
    User,
    fields=['id', 'username', 'email', 'first_name', 'last_name'],
    exclude_fields=['password'],
    custom_fields={
        'full_name': graphene.String(),
        'post_count': graphene.Int(),
    },
    custom_resolvers={
        'full_name': lambda user, info: f"{user.first_name} {user.last_name}",
        'post_count': lambda user, info: user.posts.count(),
    }
)
```

### Permission System

```python
from rail_django_graphql.permissions import BasePermission

class IsOwnerOrReadOnly(BasePermission):
    def has_permission(self, info, obj=None):
        if info.context.method == 'GET':
            return True
        return obj and obj.owner == info.context.user

# Apply to queries
posts = QueryGenerator.list_field(
    Post,
    permission_classes=[IsOwnerOrReadOnly]
)
```

### Query Optimization

```python
# Automatic optimization is enabled by default
# Manual optimization for complex queries
from rail_django_graphql.optimization import QueryOptimizer

class Query(graphene.ObjectType):
    posts = graphene.List(PostType)
    
    @QueryOptimizer.optimize(['author', 'comments__user'])
    def resolve_posts(self, info):
        return Post.objects.all()
```

## Configuration

### Settings Reference

```python
RAIL_GRAPHQL = {
    # Schema Generation
    'AUTO_GENERATE_SCHEMA': True,
    'AUTO_DISCOVER_MODELS': True,
    'SCHEMA_OUTPUT_PATH': 'schema.json',
    
    # Security
    'ENABLE_INTROSPECTION': True,  # Disable in production
    'MAX_QUERY_DEPTH': 10,
    'MAX_QUERY_COMPLEXITY': 1000,
    'ENABLE_QUERY_WHITELIST': False,
    
    # Performance
    'ENABLE_QUERY_OPTIMIZATION': True,
    'ENABLE_DATALOADER': True,
    'CACHE_TIMEOUT': 300,
    
    # Debugging
    'ENABLE_DEBUGGING': True,  # Disable in production
    'LOG_QUERIES': True,
    'LOG_SLOW_QUERIES': True,
    'SLOW_QUERY_THRESHOLD': 1.0,  # seconds
    
    # Permissions
    'DEFAULT_PERMISSION_CLASSES': [
        'rail_django_graphql.permissions.IsAuthenticated',
    ],
    'ENABLE_FIELD_PERMISSIONS': True,
    
    # Extensions
    'ENABLE_EXTENSIONS': True,
    'EXTENSION_CLASSES': [
        'rail_django_graphql.extensions.QueryComplexityExtension',
        'rail_django_graphql.extensions.PerformanceExtension',
    ],
}
```

## Development

### Setting up Development Environment

```bash
# Clone the repository
git clone https://github.com/raillogistic/rail-django-graphql.git
cd rail-django-graphql

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install development dependencies
pip install -r requirements-dev.txt

# Install the package in development mode
pip install -e .

# Run tests
python -m pytest

# Run linting
black rail_django_graphql
isort rail_django_graphql
flake8 rail_django_graphql
mypy rail_django_graphql
```

### Running Tests

```bash
# Run all tests
python -m pytest

# Run with coverage
python -m pytest --cov=rail_django_graphql --cov-report=html

# Run specific test file
python -m pytest rail_django_graphql/tests/test_generators.py

# Run with verbose output
python -m pytest -v
```

## Contributing

We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.

### Development Workflow

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Make your changes
4. Add tests for your changes
5. Run the test suite (`python -m pytest`)
6. Run linting (`black . && isort . && flake8`)
7. Commit your changes (`git commit -m 'Add amazing feature'`)
8. Push to the branch (`git push origin feature/amazing-feature`)
9. Open a Pull Request

## Documentation

- [Full Documentation](https://rail-django-graphql.readthedocs.io/)
- [API Reference](https://rail-django-graphql.readthedocs.io/en/latest/api/)
- [Examples](examples/)
- [Changelog](CHANGELOG.md)

## Requirements

- Python 3.8+
- Django 4.2+
- graphene-django 3.0+

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Support

- [GitHub Issues](https://github.com/raillogistic/rail-django-graphql/issues)
- [Discussions](https://github.com/raillogistic/rail-django-graphql/discussions)
- [Stack Overflow](https://stackoverflow.com/questions/tagged/rail-django-graphql)

## Acknowledgments

- Built on top of [Graphene-Django](https://github.com/graphql-python/graphene-django)
- Inspired by Django REST Framework's design patterns
- Thanks to all contributors and the Django/GraphQL community

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/raillogistic/rail-django-graphql",
    "name": "rail-django-graphql",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Rail Django GraphQL Contributors <contributors@rail-django-graphql.com>",
    "keywords": "django, graphql, api, graphene, schema, generator, rail, automation",
    "author": "Rail Logistic",
    "author_email": "Rail Django GraphQL Contributors <contributors@rail-django-graphql.com>",
    "download_url": "https://files.pythonhosted.org/packages/7e/74/15235266329d7b57979c5385507fb11141fc5a65418a600d847ac40c5f33/rail_django_graphql-1.1.3.tar.gz",
    "platform": null,
    "description": "# Rail Django GraphQL\r\n\r\n[![CI](https://github.com/raillogistic/rail-django-graphql/workflows/CI/badge.svg)](https://github.com/raillogistic/rail-django-graphql/actions)\r\n[![PyPI version](https://badge.fury.io/py/rail-django-graphql.svg)](https://badge.fury.io/py/rail-django-graphql)\r\n[![Python versions](https://img.shields.io/pypi/pyversions/rail-django-graphql.svg)](https://pypi.org/project/rail-django-graphql/)\r\n[![Django versions](https://img.shields.io/pypi/djversions/rail-django-graphql.svg)](https://pypi.org/project/rail-django-graphql/)\r\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\r\n\r\nA powerful Django library for automatic GraphQL schema generation with advanced features including type generation, query optimization, permissions, and comprehensive debugging tools.\r\n\r\n## Features\r\n\r\n- \ud83d\ude80 **Automatic Schema Generation**: Generate GraphQL schemas from Django models with zero configuration\r\n- \ud83d\udd27 **Type Generators**: Automatic GraphQL type creation with customizable field mappings\r\n- \ud83d\udd0d **Query Optimization**: Built-in query optimization and N+1 problem prevention\r\n- \ud83d\udee1\ufe0f **Advanced Permissions**: Flexible permission system with field-level access control\r\n- \ud83d\udc1b **Debugging Tools**: Comprehensive debugging and introspection capabilities\r\n- \ud83d\udcca **Performance Monitoring**: Built-in performance metrics and query analysis\r\n- \ud83d\udd0c **Plugin System**: Extensible architecture with custom plugins\r\n- \ud83c\udfa8 **GraphiQL Integration**: Enhanced GraphiQL interface with custom tools\r\n- \ud83d\udcdd **Auto Documentation**: Automatic API documentation generation\r\n- \ud83d\udd12 **Security Features**: Built-in security measures and validation\r\n\r\n## Installation\r\n\r\n### From PyPI (Recommended)\r\n\r\n```bash\r\npip install rail-django-graphql\r\n```\r\n\r\n### From GitHub (Development Version)\r\n\r\n```bash\r\n# Install directly from GitHub\r\npip install git+https://github.com/raillogistic/rail-django-graphql.git\r\n\r\n# Or clone and install locally\r\ngit clone https://github.com/raillogistic/rail-django-graphql.git\r\ncd rail-django-graphql\r\npip install -e .\r\n```\r\n\r\n### Optional Dependencies\r\n\r\nInstall additional features:\r\n\r\n```bash\r\n# Authentication support\r\npip install rail-django-graphql[auth]\r\n\r\n# Performance optimizations\r\npip install rail-django-graphql[performance]\r\n\r\n# Media handling\r\npip install rail-django-graphql[media]\r\n\r\n# Monitoring and metrics\r\npip install rail-django-graphql[monitoring]\r\n\r\n# All optional features\r\npip install rail-django-graphql[all]\r\n```\r\n\r\n## Quick Start\r\n\r\n### 1. Add to Django Settings\r\n\r\n```python\r\n# settings.py\r\nINSTALLED_APPS = [\r\n    'django.contrib.admin',\r\n    'django.contrib.auth',\r\n    'django.contrib.contenttypes',\r\n    'django.contrib.sessions',\r\n    'django.contrib.messages',\r\n    'django.contrib.staticfiles',\r\n    \r\n    # GraphQL dependencies\r\n    'graphene_django',\r\n    'django_filters',\r\n    'corsheaders',\r\n    \r\n    # Rail Django GraphQL\r\n    'rail_django_graphql',\r\n    \r\n    # Your apps\r\n    'your_app',\r\n]\r\n\r\n# GraphQL Configuration\r\nGRAPHENE = {\r\n    'SCHEMA': 'your_project.schema.schema',\r\n    'MIDDLEWARE': [\r\n        'rail_django_graphql.middleware.QueryOptimizationMiddleware',\r\n        'rail_django_graphql.middleware.PermissionMiddleware',\r\n        'rail_django_graphql.middleware.DebuggingMiddleware',\r\n    ],\r\n}\r\n\r\n# Rail Django GraphQL Settings\r\nRAIL_GRAPHQL = {\r\n    'AUTO_GENERATE_SCHEMA': True,\r\n    'ENABLE_DEBUGGING': True,\r\n    'ENABLE_INTROSPECTION': True,\r\n    'MAX_QUERY_DEPTH': 10,\r\n    'ENABLE_QUERY_OPTIMIZATION': True,\r\n}\r\n```\r\n\r\n### 2. Create Your Schema\r\n\r\n```python\r\n# schema.py\r\nimport graphene\r\nfrom rail_django_graphql import (\r\n    TypeGenerator,\r\n    QueryGenerator,\r\n    MutationGenerator,\r\n    SchemaBuilder\r\n)\r\nfrom your_app.models import User, Post, Comment\r\n\r\n# Generate types automatically\r\nUserType = TypeGenerator.from_model(User)\r\nPostType = TypeGenerator.from_model(Post)\r\nCommentType = TypeGenerator.from_model(Comment)\r\n\r\n# Generate queries\r\nclass Query(graphene.ObjectType):\r\n    # Auto-generated queries\r\n    users = QueryGenerator.list_field(User)\r\n    user = QueryGenerator.detail_field(User)\r\n    posts = QueryGenerator.list_field(Post)\r\n    post = QueryGenerator.detail_field(Post)\r\n    \r\n    # Custom queries\r\n    my_posts = graphene.List(PostType)\r\n    \r\n    def resolve_my_posts(self, info):\r\n        return Post.objects.filter(author=info.context.user)\r\n\r\n# Generate mutations\r\nclass Mutation(graphene.ObjectType):\r\n    create_post = MutationGenerator.create_mutation(Post)\r\n    update_post = MutationGenerator.update_mutation(Post)\r\n    delete_post = MutationGenerator.delete_mutation(Post)\r\n\r\n# Build schema\r\nschema = SchemaBuilder.build(\r\n    query=Query,\r\n    mutation=Mutation,\r\n    auto_discover=True  # Automatically discover and include all models\r\n)\r\n```\r\n\r\n### 3. Add URLs\r\n\r\n```python\r\n# urls.py\r\nfrom django.contrib import admin\r\nfrom django.urls import path, include\r\nfrom graphene_django.views import GraphQLView\r\nfrom rail_django_graphql.views.graphql_views import (\r\n    MultiSchemaGraphQLView,\r\n    SchemaListView,\r\n    GraphQLPlaygroundView,\r\n)\r\nfrom rail_django_graphql.health_urls import health_urlpatterns\r\n\r\nurlpatterns = [\r\n    path('admin/', admin.site.urls),\r\n    # Single schema endpoint (backward compatible)\r\n    path('graphql/', GraphQLView.as_view(graphiql=True)),\r\n    # Multi-schema endpoints\r\n    path('graphql/<str:schema_name>/', MultiSchemaGraphQLView.as_view(), name='graphql-by-schema'),\r\n    path('schemas/', SchemaListView.as_view(), name='graphql-schemas'),\r\n    path('playground/<str:schema_name>/', GraphQLPlaygroundView.as_view(), name='graphql-playground'),\r\n    # Health endpoints\r\n    path('health/', include(health_urlpatterns)),\r\n]\r\n```\r\n\r\n### 4. Run Migrations and Start Server\r\n\r\n```bash\r\npython manage.py migrate\r\npython manage.py runserver\r\n```\r\n\r\nVisit `http://localhost:8000/graphql/` to access the GraphiQL interface.\r\n\r\n## Advanced Usage\r\n### Multi-Schema Setup\r\n\r\nThe library supports multiple schemas with per-schema settings, endpoints, and GraphiQL control.\r\n\r\n1) Enable multi-schema in settings and register schemas via the registry:\r\n\r\n```python\r\n# settings.py\r\nRAIL_DJANGO_GRAPHQL = {\r\n    \"MULTI_SCHEMA_ENABLED\": True,\r\n}\r\n\r\n# myapp/schema_config.py\r\nfrom rail_django_graphql.core.registry import schema_registry\r\n\r\nschema_registry.register_schema(\r\n    name=\"public_api\",\r\n    description=\"Public API for customers\",\r\n    version=\"1.0.0\",\r\n    apps=[\"customers\", \"products\"],\r\n    models=[\"Customer\", \"Product\"],\r\n    enabled=True,\r\n    settings={\r\n        \"enable_graphiql\": True,\r\n        \"authentication_required\": False,\r\n    },\r\n)\r\n\r\nschema_registry.register_schema(\r\n    name=\"admin_api\",\r\n    description=\"Admin API for internal use\",\r\n    version=\"1.0.0\",\r\n    apps=[\"customers\", \"products\", \"orders\"],\r\n    models=[\"Customer\", \"Product\", \"Order\", \"User\"],\r\n    enabled=True,\r\n    settings={\r\n        \"enable_graphiql\": True,\r\n        \"authentication_required\": True,\r\n    },\r\n)\r\n```\r\n\r\n2) Configure URLs to expose per-schema endpoints:\r\n\r\n```python\r\nfrom django.urls import path\r\nfrom rail_django_graphql.views.graphql_views import MultiSchemaGraphQLView, SchemaListView, GraphQLPlaygroundView\r\n\r\nurlpatterns = [\r\n    path('graphql/<str:schema_name>/', MultiSchemaGraphQLView.as_view(), name='graphql-by-schema'),\r\n    path('schemas/', SchemaListView.as_view(), name='graphql-schemas'),\r\n    path('playground/<str:schema_name>/', GraphQLPlaygroundView.as_view(), name='graphql-playground'),\r\n]\r\n```\r\n\r\nEndpoints provided:\r\n- `GET/POST /graphql/<schema_name>/` \u2014 Execute queries against the specified schema\r\n- `GET /schemas/` \u2014 List registered schemas and their metadata\r\n- `GET /playground/<schema_name>/` \u2014 Open a schema-specific GraphQL Playground\r\n\r\n3) Control per-schema authentication and GraphiQL:\r\n\r\n```python\r\nschema_registry.register_schema(\r\n    name=\"secure_api\",\r\n    enabled=True,\r\n    settings={\r\n        \"authentication_required\": True,\r\n        \"permission_classes\": [\"django.contrib.auth.permissions.IsAuthenticated\"],\r\n        \"enable_graphiql\": False,  # Disable GraphiQL for production\r\n    },\r\n)\r\n```\r\n\r\nSee more details in `rail_django_graphql/views/graphql_views.py` and the integration tests in `rail_django_graphql/tests/integration/test_multi_schema.py`.\r\n\r\n### Custom Type Generation\r\n\r\n```python\r\nfrom rail_django_graphql import TypeGenerator\r\nfrom your_app.models import User\r\n\r\n# Basic type generation\r\nUserType = TypeGenerator.from_model(User)\r\n\r\n# Advanced type generation with custom fields\r\nUserType = TypeGenerator.from_model(\r\n    User,\r\n    fields=['id', 'username', 'email', 'first_name', 'last_name'],\r\n    exclude_fields=['password'],\r\n    custom_fields={\r\n        'full_name': graphene.String(),\r\n        'post_count': graphene.Int(),\r\n    },\r\n    custom_resolvers={\r\n        'full_name': lambda user, info: f\"{user.first_name} {user.last_name}\",\r\n        'post_count': lambda user, info: user.posts.count(),\r\n    }\r\n)\r\n```\r\n\r\n### Permission System\r\n\r\n```python\r\nfrom rail_django_graphql.permissions import BasePermission\r\n\r\nclass IsOwnerOrReadOnly(BasePermission):\r\n    def has_permission(self, info, obj=None):\r\n        if info.context.method == 'GET':\r\n            return True\r\n        return obj and obj.owner == info.context.user\r\n\r\n# Apply to queries\r\nposts = QueryGenerator.list_field(\r\n    Post,\r\n    permission_classes=[IsOwnerOrReadOnly]\r\n)\r\n```\r\n\r\n### Query Optimization\r\n\r\n```python\r\n# Automatic optimization is enabled by default\r\n# Manual optimization for complex queries\r\nfrom rail_django_graphql.optimization import QueryOptimizer\r\n\r\nclass Query(graphene.ObjectType):\r\n    posts = graphene.List(PostType)\r\n    \r\n    @QueryOptimizer.optimize(['author', 'comments__user'])\r\n    def resolve_posts(self, info):\r\n        return Post.objects.all()\r\n```\r\n\r\n## Configuration\r\n\r\n### Settings Reference\r\n\r\n```python\r\nRAIL_GRAPHQL = {\r\n    # Schema Generation\r\n    'AUTO_GENERATE_SCHEMA': True,\r\n    'AUTO_DISCOVER_MODELS': True,\r\n    'SCHEMA_OUTPUT_PATH': 'schema.json',\r\n    \r\n    # Security\r\n    'ENABLE_INTROSPECTION': True,  # Disable in production\r\n    'MAX_QUERY_DEPTH': 10,\r\n    'MAX_QUERY_COMPLEXITY': 1000,\r\n    'ENABLE_QUERY_WHITELIST': False,\r\n    \r\n    # Performance\r\n    'ENABLE_QUERY_OPTIMIZATION': True,\r\n    'ENABLE_DATALOADER': True,\r\n    'CACHE_TIMEOUT': 300,\r\n    \r\n    # Debugging\r\n    'ENABLE_DEBUGGING': True,  # Disable in production\r\n    'LOG_QUERIES': True,\r\n    'LOG_SLOW_QUERIES': True,\r\n    'SLOW_QUERY_THRESHOLD': 1.0,  # seconds\r\n    \r\n    # Permissions\r\n    'DEFAULT_PERMISSION_CLASSES': [\r\n        'rail_django_graphql.permissions.IsAuthenticated',\r\n    ],\r\n    'ENABLE_FIELD_PERMISSIONS': True,\r\n    \r\n    # Extensions\r\n    'ENABLE_EXTENSIONS': True,\r\n    'EXTENSION_CLASSES': [\r\n        'rail_django_graphql.extensions.QueryComplexityExtension',\r\n        'rail_django_graphql.extensions.PerformanceExtension',\r\n    ],\r\n}\r\n```\r\n\r\n## Development\r\n\r\n### Setting up Development Environment\r\n\r\n```bash\r\n# Clone the repository\r\ngit clone https://github.com/raillogistic/rail-django-graphql.git\r\ncd rail-django-graphql\r\n\r\n# Create virtual environment\r\npython -m venv venv\r\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\r\n\r\n# Install development dependencies\r\npip install -r requirements-dev.txt\r\n\r\n# Install the package in development mode\r\npip install -e .\r\n\r\n# Run tests\r\npython -m pytest\r\n\r\n# Run linting\r\nblack rail_django_graphql\r\nisort rail_django_graphql\r\nflake8 rail_django_graphql\r\nmypy rail_django_graphql\r\n```\r\n\r\n### Running Tests\r\n\r\n```bash\r\n# Run all tests\r\npython -m pytest\r\n\r\n# Run with coverage\r\npython -m pytest --cov=rail_django_graphql --cov-report=html\r\n\r\n# Run specific test file\r\npython -m pytest rail_django_graphql/tests/test_generators.py\r\n\r\n# Run with verbose output\r\npython -m pytest -v\r\n```\r\n\r\n## Contributing\r\n\r\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\r\n\r\n### Development Workflow\r\n\r\n1. Fork the repository\r\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\r\n3. Make your changes\r\n4. Add tests for your changes\r\n5. Run the test suite (`python -m pytest`)\r\n6. Run linting (`black . && isort . && flake8`)\r\n7. Commit your changes (`git commit -m 'Add amazing feature'`)\r\n8. Push to the branch (`git push origin feature/amazing-feature`)\r\n9. Open a Pull Request\r\n\r\n## Documentation\r\n\r\n- [Full Documentation](https://rail-django-graphql.readthedocs.io/)\r\n- [API Reference](https://rail-django-graphql.readthedocs.io/en/latest/api/)\r\n- [Examples](examples/)\r\n- [Changelog](CHANGELOG.md)\r\n\r\n## Requirements\r\n\r\n- Python 3.8+\r\n- Django 4.2+\r\n- graphene-django 3.0+\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## Support\r\n\r\n- [GitHub Issues](https://github.com/raillogistic/rail-django-graphql/issues)\r\n- [Discussions](https://github.com/raillogistic/rail-django-graphql/discussions)\r\n- [Stack Overflow](https://stackoverflow.com/questions/tagged/rail-django-graphql)\r\n\r\n## Acknowledgments\r\n\r\n- Built on top of [Graphene-Django](https://github.com/graphql-python/graphene-django)\r\n- Inspired by Django REST Framework's design patterns\r\n- Thanks to all contributors and the Django/GraphQL community\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A powerful Django library for automatic GraphQL API generation with advanced features",
    "version": "1.1.3",
    "project_urls": {
        "Bug Tracker": "https://github.com/raillogistic/rail-django-graphql/issues",
        "Changelog": "https://github.com/raillogistic/rail-django-graphql/blob/main/CHANGELOG.md",
        "Documentation": "https://rail-django-graphql.readthedocs.io/",
        "Homepage": "https://github.com/raillogistic/rail-django-graphql",
        "Repository": "https://github.com/raillogistic/rail-django-graphql.git"
    },
    "split_keywords": [
        "django",
        " graphql",
        " api",
        " graphene",
        " schema",
        " generator",
        " rail",
        " automation"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "894724cf7e9220b4cf38c8d937ef2fef7d1ae22b780ed95d150eabcded02ff22",
                "md5": "0feea905be21cc88e31273ecd85d2ed8",
                "sha256": "3eddcbc6661e7550577383661100240bda516026f87916b1518aabb4f2887f97"
            },
            "downloads": -1,
            "filename": "rail_django_graphql-1.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0feea905be21cc88e31273ecd85d2ed8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 79540,
            "upload_time": "2025-10-14T20:52:28",
            "upload_time_iso_8601": "2025-10-14T20:52:28.293430Z",
            "url": "https://files.pythonhosted.org/packages/89/47/24cf7e9220b4cf38c8d937ef2fef7d1ae22b780ed95d150eabcded02ff22/rail_django_graphql-1.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7e7415235266329d7b57979c5385507fb11141fc5a65418a600d847ac40c5f33",
                "md5": "7e9dd186d0e614235d557c86e6431706",
                "sha256": "b4ec683ab31469dbeb766218ab90a46818ab7b0bddd97af66ef909e2bff01775"
            },
            "downloads": -1,
            "filename": "rail_django_graphql-1.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "7e9dd186d0e614235d557c86e6431706",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 151523,
            "upload_time": "2025-10-14T20:52:29",
            "upload_time_iso_8601": "2025-10-14T20:52:29.993417Z",
            "url": "https://files.pythonhosted.org/packages/7e/74/15235266329d7b57979c5385507fb11141fc5a65418a600d847ac40c5f33/rail_django_graphql-1.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-14 20:52:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "raillogistic",
    "github_project": "rail-django-graphql",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "Django",
            "specs": [
                [
                    ">=",
                    "4.2.0"
                ]
            ]
        },
        {
            "name": "graphene",
            "specs": [
                [
                    ">=",
                    "3.4.0"
                ]
            ]
        },
        {
            "name": "graphene-django",
            "specs": [
                [
                    ">=",
                    "3.2.0"
                ]
            ]
        },
        {
            "name": "django-filter",
            "specs": [
                [
                    ">=",
                    "24.0.0"
                ]
            ]
        },
        {
            "name": "graphene-file-upload",
            "specs": [
                [
                    ">=",
                    "1.3.0"
                ]
            ]
        },
        {
            "name": "django-cors-headers",
            "specs": [
                [
                    ">=",
                    "4.0.0"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "rail-django-graphql"
}
        
Elapsed time: 2.00045s