Skip to main content
Pre-release

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

Strawberry GraphQL Resolver

CI Coverage Python Pydantic GraphQL Docs

Typed query builders and generated Strawberry GraphQL resolvers for Pydantic models.

Strawberry GraphQL Resolver lets clients compose filters and sorting with ordinary Python operators while servers choose whether handlers receive the original GraphQL expression, parameterized SQL, or a MongoDB query.

Highlights

  • Pydantic-first model definitions.
  • Fluent, typed query composition with all six comparison operators.
  • Automatic Strawberry input and output type generation.
  • SQL Server and MongoDB compiler support.
  • DBType.NONE for custom repositories and additional backends.
  • Nested Pydantic output models, constrained types, validators, and serializers.
  • Strict Ruff and ty checks with unit and real-database system tests.

Installation

git clone https://github.com/giladshay/strawberry-graphql-resolver.git
cd strawberry-graphql-resolver
uv sync --all-packages --all-groups

The library requires Python 3.12 or newer. See the full installation guide.

Quick start

Define a queryable model:

from collections.abc import Sequence
from typing import Self, override

from strawberry_graphql_resolver import QueryExpression, Queryable


class User(Queryable):
    name: str
    age: int

    @override
    @classmethod
    def submit(cls, query: QueryExpression) -> Sequence[Self]:
        return repository.fetch(query)


adults = User.where(User.age >= 18).sort(-User.age).submit()

Build a GraphQL resolver:

from strawberry_graphql_resolver import DBType, SQLQuery, resolve_query


@resolve_query(db=DBType.SQL)
def users(self, query: SQLQuery) -> list[User]:
    with sql_connection.cursor(as_dict=True) as cursor:
        cursor.execute(query.statement, query.parameters)
        return [User.model_validate(row) for row in cursor.fetchall()]

For MongoDB, use @resolve_query(db=DBType.MONGO_DB) and MongoDBQuery. For a custom repository, use DBType.NONE to receive the original QueryExpression.

Query operators

User.age == 18  # EQ
User.age != 18  # NEQ
User.age < 18  # LT
User.age <= 18  # LTE
User.age > 18  # GT
User.age >= 18  # GTE

+User.age  # ascending
-User.age  # descending

See the query builder guide for composition patterns and edge cases.

Testing

uv run pytest tests/unit
uv run pytest
uv run pre-commit run --all-files

The complete suite includes Testcontainers-backed tests against real SQL Server and MongoDB instances, so Docker must be running for uv run pytest to execute the system tests.

Documentation

Build documentation locally:

uv run mkdocs serve
uv run sphinx-build -W -b html docs/sphinx docs/sphinx/_build/html

Repository layout

src/strawberry_graphql_resolver/  library source
tests/unit/                       fast unit tests
tests/system/                     parameterized database tests
example/client/                   example query client
example/server/                   FastAPI and Strawberry example server
docs/                             MkDocs and Sphinx documentation
compose.yaml                      local MongoDB and SQL Server services

Contributing

Read the developer guide before making changes. New public behavior should include typed implementation, parameterized tests, documentation, and docstrings. Pull requests should pass the repository pre-commit hooks.

Releases

Maintainers manually run Create release tag in GitHub Actions. The workflow derives the tag from pyproject.toml: a normal 0.2.0 version becomes v0.2.0, while a beta version ending in b increments tags as v0.2.0b0, v0.2.0b1, and so on.

The Release workflow builds the package and documentation for v* tags. PyPI and GitHub Pages publication are protected by GitHub Environment approval gates and use PyPI Trusted Publishing through OIDC. See the developer release guide for maintainer setup.

License

See the repository for licensing information.

Metadata

Release files for strawberry-graphql-resolver 0.1.0b0

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

Source distribution (sdist)

Source distribution for strawberry-graphql-resolver 0.1.0b0
File Size Uploaded
strawberry_graphql_resolver-0.1.0b0.tar.gz 10.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for strawberry-graphql-resolver 0.1.0b0
File Interpreter ABI Platform
strawberry_graphql_resolver-0.1.0b0-py3-none-any.whl Python 3 none any Details

Total release size: 27.9 kB

Release files / strawberry_graphql_resolver-0.1.0b0.tar.gz

Download URL strawberry_graphql_resolver-0.1.0b0.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
91bb8c65ca989299e20a660f85d05a1187e816e2e5308d1cbd87c7eb363fc0b5
BLAKE2b-256 checksum
How to use checksums
4948f4ae4ea9400422db323b47291f6ab6b40748423ff1bd6c248a44fc85a9b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 16, 2026.

Transparency log

Release files / strawberry_graphql_resolver-0.1.0b0-py3-none-any.whl

Download URL strawberry_graphql_resolver-0.1.0b0-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be10d8b676a7e417ea34c7eb3b21594753ffd284bd529872bee48e1d40bc7eeb
BLAKE2b-256 checksum
How to use checksums
ab3811c7c76f4becf077c1844c702272af1db6807a0752ad487ee9617ca5e516
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0b0 This release

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