Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Graft

Graft turns your SQLModel definitions into a fully-typed GraphQL API — no schema duplication, no glue code.

CI PyPI Coverage


Overview

Graft lets you define your data models once (as GraftModel subclasses) and get a fully-typed GraphQL API automatically — no schema duplication, no glue code. It layers on top of SQLModel for the ORM and Strawberry for the GraphQL schema. Mount GraftRouter in any FastAPI app and your models are immediately queryable and mutable over GraphQL — including paginated connections, filters, ordering, and fine-grained permission hooks.

Async (SQLAlchemy async engines) and sync engines are both supported, and multiple database engines can be registered under different names for multi-tenant or federated setups.


Features

  • Single model class — extend GraftModel instead of both SQLModel and a Strawberry type.
  • Auto GraphQL schema — queries, mutations (PUT / DELETE), and paginated connections generated automatically.
  • DataLoaders — declare relations with Dl and ManyRelation; N+1 queries solved out of the box.
  • Composable filters — date ranges, ordering, and custom filter attributes, all typed.
  • Permission hooks — override permission_getter per-model or supply a global get_permission function.
  • Async support — pass an async SQLAlchemy engine and Graft handles the rest.
  • Multi-engine — register multiple engines by name; each model picks its engine via __enginename__.
  • Federation-ready — Strawberry federation directives can be applied through the schema DSL.

Installation

pip install bootgraph

Quick Start

from datetime import date

from fastapi import FastAPI
from sqlmodel import create_engine

from bootgraph import Field, GraftModel, GraftRouter

# 1. Define your models — once. No separate Pydantic/Strawberry types needed.
class Student(GraftModel, table=True):
    id: int | None = Field(primary_key=True, default=None)
    name: str
    birth_date: date

# 2. Create tables and mount the router.
engine = create_engine("sqlite:///./dev.db")
GraftModel.metadata.create_all(engine)

app = FastAPI()
router = GraftRouter(
    engine=engine,
    enable_put_mutations=True,
    enable_delete_mutations=True,
)
app.include_router(router, prefix="/graphql")

# 3. Run:  uvicorn main:app --reload
#    Visit: http://localhost:8000/graphql

You can now run queries like:

mutation {
  students {
    put(input: { name: "Alice", birthDate: "2000-01-01" }) { id }
  }
}

query {
  students {
    many { edges { node { id name birthDate } } }
  }
}

Documentation

See docs for the full guide including relations, DataLoaders, authentication, async engines, and federation.


Contributing

  1. Fork the repository at <YOUR_REPO_URL>.
  2. Create a feature branch: git checkout -b feat/my-change.
  3. Make your changes and add tests.
  4. Run the test suite: pytest.
  5. Open a pull request.

All contributions are welcome — bug reports, documentation fixes, and new features alike.


License

MIT — see LICENSE.

Metadata

Release files for bootgraph 1.21.0.dev34978

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bootgraph 1.21.0.dev34978
File Size Uploaded
bootgraph-1.21.0.dev34978.tar.gz 24.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bootgraph 1.21.0.dev34978
File Interpreter ABI Platform
bootgraph-1.21.0.dev34978-py3-none-any.whl Python 3 none any Details

Total release size: 52.7 kB

Release files / bootgraph-1.21.0.dev34978.tar.gz

Download URL bootgraph-1.21.0.dev34978.tar.gz
Size 24.7 kB
Tags Source
SHA-256 checksum
How to use checksums
46fe376862a5095be8d7532eba42022d9a2682346b19148bb50b95c3eb476929
BLAKE2b-256 checksum
How to use checksums
22dc29dcf7725a098e3fcd440b158a30431fcfdc2adb72fb7a067ee0a96912d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / bootgraph-1.21.0.dev34978-py3-none-any.whl

Download URL bootgraph-1.21.0.dev34978-py3-none-any.whl
Size 28.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c643258ff7146845abc90e2550ab802bc9925548533ab05100f8486dc29fa357
BLAKE2b-256 checksum
How to use checksums
5cf711ed0c2a8def510756a8f1213f799f5e2dfa127316662cb506f77d583fcd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

1.20.0

2 release files

1.19.2

2 release files

1.19.1

2 release files

1.19.0

2 release files

1.18.0

2 release files

1.17.0

2 release files

1.16.0

2 release files

1.15.0

2 release files

1.14.1

2 release files

1.12.0

2 release files

1.11.0

2 release files

1.10.0

2 release files

1.9.0

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page