A FastAPI and Strawberry GraphQL library to create CRUD APIs over MongoDB with advanced filtering capabilities.
Project description
🦥 LazyQL
LazyQL is a powerful Python library designed to instantly generate full-featured GraphQL CRUD APIs using Pydantic models and MongoDB (via Motor).
It automates the tedious parts of backend development—schema generation, resolvers, filtering, and database interactions—while providing built-in enterprise-grade features like audit logging, soft deletes, and field-level permissions.
🚀 Key Features
- Instant CRUD: Generate Strawberry GraphQL
QueryandMutationtypes directly from Pydantic models. - MongoDB & Async: Built on top of
motorfor high-performance asynchronous database interactions. - Advanced Filtering: Built-in support for rich filters (e.g.,
name_contains,age_gte,tags_in). - Audit Logging: Automatic tracking of all changes (Create, Update, Delete, Restore) in a Time Series collection.
- Soft Deletes: Native support for soft deletion and restoration of documents.
- Permissions: Granular permission system for
create,update,delete, andlistoperations. - ACID Transactions: Support for MongoDB transactions when a client session is available.
- Extensible: Easily customize and extend generated resolvers and schemas.
📦 Installation
pip install lazyql
⚡ Quick Start
Define your data model and generate a GraphQL API in seconds.
1. Define your Model
Inherit from BaseDBModel to get automatic ID, timestamps (created_at, updated_at), and audit fields.
from lazyql import BaseDBModel
from pydantic import Field
class User(BaseDBModel):
name: str
email: str
role: str = Field(default="user")
age: int
2. Generate GraphQL Schema
Use create_crud_api to build the Query and Mutation classes.
import strawberry
from lazyql import create_crud_api
# Generate CRUD resolvers
Query, Mutation = create_crud_api(
model=User,
collection_name="users"
)
# Create the executable schema
schema = strawberry.Schema(query=Query, mutation=Mutation)
3. Run It
Integrate with your favorite ASGI framework (e.g., FastAPI, Starlette).
📄 License
LazyQL is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lazyql-0.1.2.tar.gz.
File metadata
- Download URL: lazyql-0.1.2.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32ef0e37690c6b53f9c09820bfed55e4d70e790e58306ad8a2a8a652c3fbe086
|
|
| MD5 |
390ac3ef17c98748a111e8f48d75df2b
|
|
| BLAKE2b-256 |
f9b0359d6b93ff54f79f1e3c16c6a053637b59ad0a9aa8e5a7447bc93d5765d5
|
File details
Details for the file lazyql-0.1.2-py3-none-any.whl.
File metadata
- Download URL: lazyql-0.1.2-py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6182c09cf060abe2fcbee2d1b122dbb7cab9ae7db87b63d6d28a38a2b099498a
|
|
| MD5 |
cce75bcd49282fe76d7f1c1142c100b8
|
|
| BLAKE2b-256 |
3c9b4d70e359484cffc16d981671e478f84583a04d5cd2dfca2a2c6f01224453
|