Metadata-Version: 2.4
Name: strawberry-chemist
Version: 0.1.0
Summary: Strawberry GraphQL helpers for SQLAlchemy models.
Author: strawberry-chemist contributors
License: MIT License
        
        Copyright (c) 2026 strawberry-chemist contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: async,graphql,sqlalchemy,strawberry
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Database
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: <3.13,>=3.11
Requires-Dist: bidict>=0.23.1
Requires-Dist: graphql-core>=3.2.6
Requires-Dist: greenlet>=3.2.2
Requires-Dist: sqlalchemy>=2.0.41
Requires-Dist: strawberry-graphql==0.211.1
Description-Content-Type: text/markdown

# 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

```bash
pip install strawberry-chemist
```

Supported Python versions:

- 3.11
- 3.12

## Minimal example

```python
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:

```bash
uv run pytest
```

Run formatter and type checks:

```bash
uv run pre-commit run --all-files
```

## Changelog

Release notes live in [CHANGELOG.md](CHANGELOG.md).

## Limitations

Current behavioral constraints and relay ID caveats are documented in
[LIMITATIONS.md](LIMITATIONS.md).
