Skip to content

fix(graphql): UUID/DateTime/Date/Time as first-class scalars (6.1.0) - #306

Merged
allmonday merged 1 commit into
masterfrom
fix/graphql-scalar-types
Aug 7, 2026
Merged

fix(graphql): UUID/DateTime/Date/Time as first-class scalars (6.1.0)#306
allmonday merged 1 commit into
masterfrom
fix/graphql-scalar-types

Conversation

@allmonday

Copy link
Copy Markdown
Collaborator

Port of nexusx #104 / #92 / #105. uuid.UUID, datetime, date, time all fell back to String — the scalar map only knew int/str/float/bool and map_scalar_type used fragile substring matching.

Root cause (verified on master)

  • id: UUIDid: String!, created_at: datetimeString!, d: dateString!, t: timeString!
  • Introspection advertised only Int/Float/String/Boolean/IDUUID/DateTime/Date/Time missing, so GraphiQL couldn't discover them
  • list[UUID] / list[datetime] / single @query/@mutation params arrived as raw str → crashes SQLAlchemy/SQLModel on UUID/datetime column binding

Fix

  • type_mapping.py: subclass-matched UUID/datetime/time/date (datetime ordered before date) → SDL + introspection field type-refs render UUID!/DateTime!/Date!/Time!
  • type_registry.py: register the 4 scalars in SCALAR_TYPES; derive TypeRegistry._scalars from it (kills the two-list drift)
  • introspection_generator.py: advertise every SCALAR_TYPES entry (was a hardcoded 5-name list)
  • executor.py: _convert_scalar_value / _coerce_scalar coerce these args from string to the real object, recursing through list[T], Optional[T], Optional[list[T]]

Verification

  • New repros: list[UUID][UUID], list[datetime][datetime], single UUID/date/time→real objects, Optional[list[UUID]][UUID]
  • tests/graphql/: 252 passed (was 248, +4). Tightened test_datetime_support (pinned scalar names, real UUID type, dropped the permissive String OR) + added list[UUID]/list[datetime]/single-scalar arg-conversion regressions + introspection-advertising check
  • tests/ + demo/: 905 passed, 1 skipped
  • ruff: clean

Not bugs (verified — not ported)

Version

6.1.0 (minor) — SDL surface change: fields/args of these types change StringUUID/DateTime/Date/Time. Transport unchanged. SDL consumers (codegen/Apollo) should regenerate. Decimal unchanged. Bumps pyproject.toml + uv.lock + changelog; publish via v6.1.0 tag after merge.

🤖 Generated with Claude Code

Port of nexusx #104 / #92 / #105. uuid.UUID, datetime, date, and time
previously fell back to String everywhere — the scalar map only knew
int/str/float/bool and map_scalar_type used fragile substring matching.

- type_mapping: subclass-matched UUID/datetime(time)/date scalars
  (datetime ordered before date) so SDL + introspection field type-refs
  render UUID!/DateTime!/Date!/Time! instead of String!
- type_registry: register the four scalars in SCALAR_TYPES; derive
  TypeRegistry._scalars from it so the two lists can't drift
- introspection_generator: advertise every SCALAR_TYPES entry (was a
  hardcoded 5-name list)
- executor._convert_arguments: coerce UUID/datetime/date/time args —
  including list[T], Optional[T], Optional[list[T]] — from string to the
  real Python object via a recursing _convert_scalar_value/_coerce_scalar
- tests: tighten test_datetime_support (pin the scalar names, use a real
  UUID type, drop the permissive String OR) and add list[UUID] /
  list[datetime] / single-scalar arg-conversion regressions + an
  introspection advertising check

SDL surface change (minor, not patch): String -> UUID/DateTime/Date/Time.
Transport unchanged. 905 passed (tests/ + demo/).

Co-Authored-By: Claude <noreply@anthropic.com>
@allmonday
allmonday merged commit 1fbf8b0 into master Aug 7, 2026
1 check passed
@allmonday
allmonday deleted the fix/graphql-scalar-types branch August 7, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant