Skip to content

fix(date_time): support native date/time scalars end-to-end#92

Merged
allmonday merged 2 commits into
masterfrom
fix/date-time-scalar-support
Jun 29, 2026
Merged

fix(date_time): support native date/time scalars end-to-end#92
allmonday merged 2 commits into
masterfrom
fix/date-time-scalar-support

Conversation

@allmonday

Copy link
Copy Markdown
Collaborator

Summary

SQLModel entities with date / time fields previously round-tripped through GraphQL as strings, breaking mutations and producing misleading SDL. This PR fixes three localized spots so date and time behave like the existing datetime handling.

Reproduces the bug discovered in the child-calendar project: a model with when: date / start_time: time made GraphiQL show String!, mutations hit TypeError: SQLite Date type only accepts Python date objects, and the scalars weren't even listed in introspection.

Changes

  • type_converter.SCALAR_TYPE_MAP — add date -> Date, time -> Time so SDL and introspection stop falling back to String.
  • argument_builder._convert_scalar_value — parse ISO date/time strings back to native datetime.date / datetime.time via fromisoformat, mirroring the existing datetime branch.
  • introspection._build_scalar_types — advertise Date and Time alongside DateTime.

sdl_generator needed no change — it already reads from the converter via get_scalar_type_name(...) or "String", so the fix in the converter propagates automatically.

Test plan

  • New tests/test_date_time_arguments.py — 16 tests across 5 layers (TypeConverter, SDL, ArgumentBuilder, Introspection, E2E SQLite persistence). All green.
  • Existing related suites (test_argument_types.py, test_sdl_generator.py, test_introspection.py, test_query_parser.py) — 116 passed, no regressions.
  • Full suite — 1112 passed, 6 skipped, 0 failed.

🤖 Generated with Claude Code

allmonday and others added 2 commits June 29, 2026 14:03
Reproduces the child-calendar bug: SQLModel entities with ``date`` /
``time`` fields round-trip through GraphQL as strings, causing SQLite
``TypeError`` on mutation and SDL emitting ``String!`` for what should
be ``Date!`` / ``Time!``.

Covers four layers — TypeConverter scalar map, SDL emission,
ArgumentBuilder string→object conversion, Introspection scalar list —
plus an E2E persistence test.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
A SQLModel entity with ``date`` / ``time`` fields previously round-tripped
through GraphQL as strings: SDL emitted ``String!`` for what should be
``Date!`` / ``Time!``, mutations hit SQLite ``TypeError: SQLite Date type
only accepts Python date objects``, and GraphiQL introspection didn't
even advertise the scalars. Three localized fixes:

* type_converter.SCALAR_TYPE_MAP — add ``date`` -> ``Date`` and
  ``time`` -> ``Time`` so SDL and introspection stop falling back to
  ``String``.
* argument_builder._convert_scalar_value — parse ISO date/time strings
  back into native ``datetime.date`` / ``datetime.time`` via
  ``fromisoformat`` (mirrors the existing datetime handling).
* introspection._build_scalar_types — advertise ``Date`` and ``Time``
  alongside ``DateTime`` so clients can discover them.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@allmonday allmonday merged commit 1983935 into master Jun 29, 2026
5 checks passed
allmonday added a commit that referenced this pull request Jun 29, 2026
Version bump for #91 (self/mutual recursive DTO RecursionError) and
#92 (date/time scalars round-tripping as String). Updates CHANGELOG,
pyproject.toml, uv.lock.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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