Skip to content

Migrate BigInt scalar to scalar_map and update dependencies - #260

Merged
Ckk3 merged 14 commits into
strawberry-graphql:mainfrom
Ckk3:update-deps-and-fix-bigint-scalar
Aug 31, 2026
Merged

Migrate BigInt scalar to scalar_map and update dependencies#260
Ckk3 merged 14 commits into
strawberry-graphql:mainfrom
Ckk3:update-deps-and-fix-bigint-scalar

Conversation

@Ckk3

@Ckk3 Ckk3 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes the DeprecationWarning raised on importing strawberry_sqlalchemy_mapper, and brings the
supported strawberry-graphql and Python versions up to date.

strawberry-graphql 0.288.0 deprecated passing a type to strawberry.scalar(), which is how
BigInt was built — so merely importing this package emitted a warning. BigInt is now a plain
NewType, with its scalar definition exposed as strawberry_sqlalchemy_scalar_map for
registration on the schema.

Adopting the replacement API pulled in a few unavoidable consequences, which is why this PR is
larger than the original issue suggests:

  • scalar_map only exists in strawberry-graphql >= 0.288.0, so the floor had to move.
  • That release requires Python >= 3.10, so support for 3.8/3.9 had to be dropped (both are EOL).
  • Moving to a current strawberry-graphql surfaced two pre-existing incompatibilities in
    relay.py and in the relay tests.

The commits are split by context and can be reviewed independently:

Commit Contents
81d0054 Drop Python 3.8/3.9, require 3.10+ (pyproject, CI matrix, nox, RTD, devcontainer, action images)
6ed13ba Migrate BigInt to StrawberryConfig.scalar_map
b55867b Update relay types and tests for newer strawberry-graphql
b4dbf39 Update dependencies and lint configuration
d07d097 Add RELEASE.md

Breaking changes

  1. BigInteger columns require registering the scalar map. Nothing else in the library needs
    changing, but a schema with BigInteger columns will not build without it:

    from strawberry.schema.config import StrawberryConfig
    from strawberry_sqlalchemy_mapper import strawberry_sqlalchemy_scalar_map
    
    schema = strawberry.Schema(
        query=Query,
        config=StrawberryConfig(scalar_map=strawberry_sqlalchemy_scalar_map),
    )
  2. Minimum strawberry-graphql is now 0.288.0.

  3. Python 3.8 and 3.9 are no longer supported.

  4. Relay node ids are exposed as ID instead of GlobalID, following the
    relay_use_legacy_global_id default upstream. Client queries must use $id: ID!, or set
    StrawberryConfig(relay_use_legacy_global_id=True) to keep the old name.

RELEASE.md also documents a fifth, upstream-caused change: combining first with before on a
connection returns a different page since strawberry-graphql
0.322.2 corrected the
slicing. Our test_query_with_last_and_before was passing first despite its name, and relied on
the old behaviour; it now uses last, which is what it always intended to cover.

Also fixed along the way

  • typing-extensions was an undeclared dependency. It is imported at runtime in field.py
    and mapper.py, but only resolved because strawberry-graphql happens to require it. Now
    declared explicitly.
  • scalars.py had no test coverage at all; tests/test_scalars.py is the first.

Testing

Run against PostgreSQL in containers, not just locally:

  • SQLAlchemy 2.0 on Python 3.10, 3.11, 3.12 and 3.13 — all green
  • SQLAlchemy 1.4 (1.4.54) on Python 3.11 — green
  • mypy and ruff check / ruff format — clean
  • Both GitHub action images rebuilt and smoke-tested on Python 3.10

Windows was not exercised locally (SUPPORTED_DBS is empty there, so the database tests skip).

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything.

Summary by Sourcery

Modernize scalar registration and Strawberry GraphQL compatibility while raising the supported Python baseline to 3.10.

Bug Fixes:

  • Eliminate the deprecation warning emitted when importing the package by modernizing the BigInt scalar integration.
  • Update Relay compatibility for newer strawberry-graphql behavior, including edge resolution and node ID handling.

Enhancements:

  • Expose BigInt through a configurable scalar map that must be registered for BigInteger fields.
  • Raise the minimum supported versions to Python 3.10 and strawberry-graphql 0.288.0, and declare typing-extensions explicitly.
  • Refresh development tooling and CI environments while simplifying Python-version-specific code.

Build:

  • Update dependency locks and development dependencies, including mypy, pytest, ruff, and nox.

CI:

  • Modernize GitHub Actions checkout and permissions and update the supported Python test matrix and action images.

Documentation:

  • Document BigInt scalar-map registration, updated compatibility requirements, and other release-impacting Relay changes.

Tests:

  • Add coverage for BigInt schema registration, BigInteger mapping, and serialization of values beyond 32-bit ranges.
  • Update Relay tests for current pagination and node ID behavior.

Chores:

  • Add release notes describing breaking changes and dependency updates.

@codspeed-hq

codspeed-hq Bot commented Aug 31, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 74.72%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

#### 🎉 Hooray! `pytest-codspeed` just leveled up to 5.0.3!

A heads-up, this is a breaking change and it might affect your current performance baseline a bit. But here's the exciting part - it's packed with new, cool features and promises improved result stability 🥳!
Curious about what's new? Visit our releases page to delve into all the awesome details about this new version.

⚡ 1 improved benchmark

Performance Changes

Benchmark BASE HEAD Efficiency
test_hello_world 18.3 µs 10.5 µs +74.72%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing Ckk3:update-deps-and-fix-bigint-scalar (ce887ed) with main (00d109c)

Open in CodSpeed

@codecov-commenter

codecov-commenter commented Aug 31, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.50%. Comparing base (3780367) to head (ce887ed).
⚠️ Report is 1 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #260      +/-   ##
==========================================
+ Coverage   92.47%   92.50%   +0.03%     
==========================================
  Files          19       20       +1     
  Lines        2445     2469      +24     
  Branches      188      185       -3     
==========================================
+ Hits         2261     2284      +23     
- Misses         98       99       +1     
  Partials       86       86              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Ckk3
Ckk3 marked this pull request as ready for review August 31, 2026 22:07
@botberry

Copy link
Copy Markdown
Member

Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:


Migrate the BigInt scalar to StrawberryConfig.scalar_map and raise the supported
strawberry-graphql and Python versions.

BigInt was built by passing a type to strawberry.scalar(), a pattern deprecated in
strawberry-graphql 0.288.0, so simply importing strawberry_sqlalchemy_mapper emitted a
DeprecationWarning. BigInt is now a plain NewType and its scalar definition is exposed as
strawberry_sqlalchemy_scalar_map.

Fixes #259.

Breaking Changes:

  • If your models use BigInteger columns, you must now register the scalar map on your schema:
import strawberry
from strawberry.schema.config import StrawberryConfig
from strawberry_sqlalchemy_mapper import strawberry_sqlalchemy_scalar_map

schema = strawberry.Schema(
    query=Query,
    config=StrawberryConfig(scalar_map=strawberry_sqlalchemy_scalar_map),
)

If you already maintain your own scalar_map, merge the two:

config = StrawberryConfig(
    scalar_map={**strawberry_sqlalchemy_scalar_map, **my_scalar_map},
)

Forgetting to register it raises TypeError: ... fields cannot be resolved. Unexpected type '...BigInt' when the schema is built.

See Custom scalars in the Strawberry
documentation for more about scalar_map.

  • The minimum strawberry-graphql version is now 0.288.0, which is where scalar_map was added.

  • Python 3.8 and 3.9 are no longer supported. strawberry-graphql 0.288.0 requires Python 3.10
    or newer, and both versions have reached end of life.

  • Combining first with before on a connection now returns a different page. Older
    strawberry-graphql releases walked backward from the before cursor, effectively behaving
    like last. This was corrected in strawberry-graphql
    0.322.2, so before
    now bounds the range and first takes from its start, per the Relay Cursor Connections spec.
    Queries relying on the previous behaviour should use last.

  • Relay node ids are now exposed as the ID scalar instead of GlobalID, following the
    relay_use_legacy_global_id default in newer strawberry-graphql versions. Queries written
    against the generated schema must use ID (for example query Fruit($id: ID!)). Pass
    StrawberryConfig(relay_use_legacy_global_id=True) to keep the previous GlobalID naming.

Fixes:

  • import strawberry_sqlalchemy_mapper no longer emits a DeprecationWarning.
  • Edge.resolve_edge now accepts the additional keyword arguments its strawberry.relay
    supertype may pass to it.

Internal:

  • Removed the sys.version_info branches that supported Python 3.8/3.9, in
    strawberry_sqlalchemy_mapper/__init__.py and the annotation merging in
    StrawberrySQLAlchemyMapper.type().
  • Dropped the importlib-metadata dependency, unused now that importlib.metadata is always
    available.
  • Declared typing-extensions as an explicit dependency. It is imported directly by the mapper
    but was previously only installed as a transitive dependency of strawberry-graphql.
  • Updated development dependencies: ruff 0.16, mypy 2.3, pytest 9, pytest-asyncio 1.4,
    pytest-cov 7, pytest-codspeed 5, pytest-mypy-plugins 4, pytest-xdist 3.8 and nox 2026.
  • Set the ruff target and pyright version to Python 3.10, ignored the additional rules that
    conflict with the project's runtime-typing conventions (UP035, UP045, CPY001, PLC0415,
    PLW0108, PYI061, PYI016, FURB110), and removed ANN101/ANN102, which ruff no longer
    implements.
  • Updated the CI test matrix, noxfile.py, the devcontainer image, Read the Docs and the
    GitHub action images to Python 3.10.
  • Added tests/test_scalars.py, covering the BigInt scalar: schema registration, the
    BigInteger column mapping and serialization of values above 32 bits.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Fixed security issues:

  • strawberry-graphql (link)
  • wheel (link)
Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/strawberry_sqlalchemy_mapper/scalars.py" line_range="16" />
<code_context>
+        description="BigInt field",
+        serialize=lambda v: int(v),
+        parse_value=lambda v: str(v),
+    ),
+}
</code_context>
<issue_to_address>
**issue (bug_risk):** `parse_value` returns a `str`, but `BigInt` is now declared as `NewType("BigInt", int)`, so GraphQL inputs annotated as `BigInt` are delivered to resolvers as strings despite their type contract. Resolver code performing numeric operations receives string values and can fail or produce incorrect results.

**Triggers:** When a schema uses `BigInt` as an input or argument type and a client supplies a value.

**Suggested fix:** Return `int(v)` from `parse_value` so the runtime value matches the `BigInt`/`int` annotation.

```suggestion
        parse_value=lambda v: int(v),
```
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: src/strawberry_sqlalchemy_mapper/scalars.py:16


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

name="BigInt",
description="BigInt field",
serialize=lambda v: int(v),
parse_value=lambda v: str(v),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): parse_value returns a str, but BigInt is now declared as NewType("BigInt", int), so GraphQL inputs annotated as BigInt are delivered to resolvers as strings despite their type contract. Resolver code performing numeric operations receives string values and can fail or produce incorrect results.

Triggers: When a schema uses BigInt as an input or argument type and a client supplies a value.

Suggested fix: Return int(v) from parse_value so the runtime value matches the BigInt/int annotation.

Suggested change
parse_value=lambda v: str(v),
parse_value=lambda v: int(v),

@Ckk3
Ckk3 merged commit a660daf into strawberry-graphql:main Aug 31, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BigInt triggers strawberry.scalar deprecation warning

3 participants