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.4.tar.gz (20.4 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.4-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lazyql-0.1.4.tar.gz
  • Upload date:
  • Size: 20.4 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.4.tar.gz
Algorithm Hash digest
SHA256 c69962c62f871a4e21c4fe31abf6632d05f02e8741428a9e4649885c7319135b
MD5 08e169f8a4077864b937125fede4aae1
BLAKE2b-256 1b4f5042d6374a5f07cf6643e00d9947cd2f08a9c5657f0561712f7325dd9598

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lazyql-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 27.7 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ed977c8c718b6c4835c7c5710c3c50016e0225c2c18f2766466213f4d58a431b
MD5 17bf710a37cc075a6e73820d78c0f47a
BLAKE2b-256 522238dc068ba78b75362d794b8f65b590ea8b88ec87d725f10fdf08de33f58b

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