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.3.tar.gz (20.3 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.3-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lazyql-0.1.3.tar.gz
  • Upload date:
  • Size: 20.3 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.3.tar.gz
Algorithm Hash digest
SHA256 d328eedee075cd136ee780f753b523d61665de4df31cc15a5997ccf7e593faa9
MD5 1a3c098da89a00d9066964ed9c180f45
BLAKE2b-256 dc057cea0a502eb975931eeeaf8e5ef0fc094f6df355ad23eda70fc972ba6300

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lazyql-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4e622733510d236f60486107df156328b193587b7751c731f5588755bf75d12d
MD5 009378fd8f2b096245d0af7f69dd8b3d
BLAKE2b-256 0b369786659f057b8b079f6bd5419ffd5887eb843d820adc118d1b6c6aa3de5a

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