This release is a pre-release and may not be stable for production use.
SQLModel in, typed GraphQL out.
GraftQL turns your SQLModel definitions into a fully-typed GraphQL API — no schema duplication, no glue code.
Overview
GraftQL 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 GraftQL 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 graftql
Pull requests from branches in this repository publish development releases for testing. These
releases use versions such as 2.0.5.dev123456, so pip ignores them during normal installation.
Install a specific preview using the version shown in the pull request workflow summary:
pip install "graftql==2.0.5.dev123456"
Quick Start
from datetime import date
from fastapi import FastAPI
from sqlmodel import create_engine
from graftql 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 the documentation for the full guide including relations, DataLoaders, authentication, async engines, and federation.
Contributing
- Fork lorrod/graftql.
- Create a feature branch:
git checkout -b feat/my-change. - Make your changes and add tests.
- Run the checks:
uv run --group dev ruff check . && uv run --group dev pytest. - Open a pull request whose title follows Conventional Commits, for example
feat(api): add cursor filteringorfix: handle missing relationships.
All contributions are welcome — bug reports, documentation fixes, and new features alike.
License
MIT — see LICENSE.
Metadata
Release files for graftql 2.0.6.dev41329372149
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| graftql-2.0.6.dev41329372149-py3-none-any.whl | Python 3 | none | any | Details for graftql-2.0.6.dev41329372149-py3-none-any.whl |
Release files / graftql-2.0.6.dev41329372149-py3-none-any.whl
| Download URL | graftql-2.0.6.dev41329372149-py3-none-any.whl |
|---|---|
| Size | 28.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
16dfc98119890ddf638e488b2e251ed14a9a834387e496c3a203a106715e66ce
|
|
BLAKE2b-256 checksum How to use checksums |
28cac19216552818f49ca144ba1ef2c699cd0c98ec16196468efe836cfdcde1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logSecurity for graftql 2.0.6.dev41329372149
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 1 file in this release has been uploaded with provenance metadata.
Attestation for graftql-2.0.6.dev41329372149-py3-none-any.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.