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.1.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.1-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

Details for the file lazyql-0.1.1.tar.gz.

File metadata

  • Download URL: lazyql-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 a30fb91a39c973dc1e9090f5ad8c5aff6a3f2440bc4ec327bba6e573e7c829c9
MD5 7dd5316ae7a15d4ce87763670d54394d
BLAKE2b-256 8002d39e297d58179580c0f974838d716bfe8c0ca282ba032140b1d9fd90a285

See more details on using hashes here.

File details

Details for the file lazyql-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: lazyql-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 27.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a1cb3d682cb699f37426a94493b11e745392163b39d2ccd59409ea458ba3ae9f
MD5 9981053c69ac00fecc35c33bb5fea3da
BLAKE2b-256 5fb7a44cc5d75c0f5a36331a167809d8230876ade7e614d583d3fcc53eb4cadf

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