Strawberry GraphQL helpers for SQLAlchemy models.
Project description
strawberry-chemist
Helpers for exposing SQLAlchemy models through Strawberry GraphQL with less boilerplate.
This package wraps common patterns for:
- generating Strawberry types from SQLAlchemy models
- exposing model fields and relationships
- relay-style IDs and connections
- connection filtering, ordering, and pagination
Status
This project is currently alpha. The API is usable, but you should still expect some rough edges and breaking changes while the standalone package settles.
Installation
pip install strawberry-chemist
Supported Python versions:
- 3.11
- 3.12
Minimal example
from typing import Optional
import strawberry
import strawberry_chemist
from sqlalchemy import Integer, String, select
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
from strawberry.types import Info
from strawberry_chemist.gql_context import SQLAlchemyContext
class Base(DeclarativeBase):
pass
class Book(Base):
__tablename__ = "book"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
title: Mapped[str] = mapped_column(String)
@strawberry_chemist.type(model=Book)
class BookNode:
title: str
@strawberry.type
class Query:
@strawberry.field
async def book_by_title(
self, info: Info[SQLAlchemyContext, None], title: str
) -> Optional[BookNode]:
async with info.context.get_session() as session:
return (
await session.execute(select(Book).where(Book.title == title))
).scalar_one_or_none()
schema = strawberry.Schema(query=Query)
Your GraphQL context must provide a get_session() async context manager that
returns a SQLAlchemy AsyncSession.
Development
Run the default non-Postgres test suite:
uv run pytest
Run formatter and type checks:
uv run pre-commit run --all-files
Changelog
Release notes live in CHANGELOG.md.
Limitations
Current behavioral constraints and relay ID caveats are documented in LIMITATIONS.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file strawberry_chemist-0.1.0.tar.gz.
File metadata
- Download URL: strawberry_chemist-0.1.0.tar.gz
- Upload date:
- Size: 78.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89b962a0fd21b663834237921a0e2643b5191544bfba4ab23b2e6a3ba73c3e7e
|
|
| MD5 |
bc98ff2abd3a24c9c6b91dfb69d30561
|
|
| BLAKE2b-256 |
811524fb918a352f9ebe4fbe311928f1509eb437dba418ae195cd06a4dab8c7e
|
Provenance
The following attestation bundles were made for strawberry_chemist-0.1.0.tar.gz:
Publisher:
publish.yml on MeRuslan/strawberry-chemist
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
strawberry_chemist-0.1.0.tar.gz -
Subject digest:
89b962a0fd21b663834237921a0e2643b5191544bfba4ab23b2e6a3ba73c3e7e - Sigstore transparency entry: 1078138527
- Sigstore integration time:
-
Permalink:
MeRuslan/strawberry-chemist@6f9f69bdf0a4e8eb995f641d095d92970ea4cbbd -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/MeRuslan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6f9f69bdf0a4e8eb995f641d095d92970ea4cbbd -
Trigger Event:
release
-
Statement type:
File details
Details for the file strawberry_chemist-0.1.0-py3-none-any.whl.
File metadata
- Download URL: strawberry_chemist-0.1.0-py3-none-any.whl
- Upload date:
- Size: 37.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ddd2d5da4e3aa55a46b4dcb2d7bb4050a4c84668857430eadd3abb9d6cd7170
|
|
| MD5 |
527043dc14a94b80926538b38b92f70e
|
|
| BLAKE2b-256 |
d9cc9c3941221bc267607393398ebb0b9e1e246389e27b87b03f3d3e66d98545
|
Provenance
The following attestation bundles were made for strawberry_chemist-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on MeRuslan/strawberry-chemist
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
strawberry_chemist-0.1.0-py3-none-any.whl -
Subject digest:
0ddd2d5da4e3aa55a46b4dcb2d7bb4050a4c84668857430eadd3abb9d6cd7170 - Sigstore transparency entry: 1078138554
- Sigstore integration time:
-
Permalink:
MeRuslan/strawberry-chemist@6f9f69bdf0a4e8eb995f641d095d92970ea4cbbd -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/MeRuslan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6f9f69bdf0a4e8eb995f641d095d92970ea4cbbd -
Trigger Event:
release
-
Statement type: