Skip to main content

A FastAPI and Strawberry GraphQL library to create CRUD APIs over MongoDB with advanced filtering capabilities.

Project description

🦥 LazyQL

LazyQL Logo PyPI version Python versions License pipeline status coverage report Code style: ruff Checked with mypy

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 Query and Mutation types directly from Pydantic models.
  • MongoDB & Async: Built on top of motor for 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, and list operations.
  • 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lazyql-0.1.2.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lazyql-0.1.2-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

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

Hashes for lazyql-0.1.2.tar.gz
Algorithm Hash digest
SHA256 32ef0e37690c6b53f9c09820bfed55e4d70e790e58306ad8a2a8a652c3fbe086
MD5 390ac3ef17c98748a111e8f48d75df2b
BLAKE2b-256 f9b0359d6b93ff54f79f1e3c16c6a053637b59ad0a9aa8e5a7447bc93d5765d5

See more details on using hashes here.

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

Hashes for lazyql-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6182c09cf060abe2fcbee2d1b122dbb7cab9ae7db87b63d6d28a38a2b099498a
MD5 cce75bcd49282fe76d7f1c1142c100b8
BLAKE2b-256 3c9b4d70e359484cffc16d981671e478f84583a04d5cd2dfca2a2c6f01224453

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page