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.
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
GraftModelinstead of bothSQLModeland a Strawberry type. - Auto GraphQL schema — queries, mutations (PUT / DELETE), and paginated connections generated automatically.
- DataLoaders — declare relations with
DlandManyRelation; N+1 queries solved out of the box. - Composable filters — date ranges, ordering, and custom filter attributes, all typed.
- Permission hooks — override
permission_getterper-model or supply a globalget_permissionfunction. - 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
- Fork the repository at
<YOUR_REPO_URL>. - Create a feature branch:
git checkout -b feat/my-change. - Make your changes and add tests.
- Run the test suite:
pytest. - 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.dev34977
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bootgraph-1.21.0.dev34977.tar.gz | 24.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bootgraph-1.21.0.dev34977-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 52.7 kB
Release files / bootgraph-1.21.0.dev34977.tar.gz
| Download URL | bootgraph-1.21.0.dev34977.tar.gz |
|---|---|
| Size | 24.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
54380922cc49f46ba1357a27055ad99e989f514d61923b1a0a8ee94fbf499358
|
|
BLAKE2b-256 checksum How to use checksums |
14256ede2088600a277904385c143d778f0a3ccc1c0067fae36b3d2ccf3eb73f
|
| 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.dev34977-py3-none-any.whl
| Download URL | bootgraph-1.21.0.dev34977-py3-none-any.whl |
|---|---|
| Size | 28.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b454827378ca642456933aeb65900d258e170573e73329cb5180b76e36db46d2
|
|
BLAKE2b-256 checksum How to use checksums |
b0da34be6aeb7b51d36b8749eeb04eba5753c416393218366b2425dffae13f6c
|
| 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}
|