fix(date_time): support native date/time scalars end-to-end#92
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SQLModel entities with
date/timefields previously round-tripped through GraphQL as strings, breaking mutations and producing misleading SDL. This PR fixes three localized spots sodateandtimebehave like the existingdatetimehandling.Reproduces the bug discovered in the child-calendar project: a model with
when: date/start_time: timemade GraphiQL showString!, mutations hitTypeError: SQLite Date type only accepts Python date objects, and the scalars weren't even listed in introspection.Changes
type_converter.SCALAR_TYPE_MAP— adddate->Date,time->Timeso SDL and introspection stop falling back toString.argument_builder._convert_scalar_value— parse ISO date/time strings back to nativedatetime.date/datetime.timeviafromisoformat, mirroring the existingdatetimebranch.introspection._build_scalar_types— advertiseDateandTimealongsideDateTime.sdl_generatorneeded no change — it already reads from the converter viaget_scalar_type_name(...) or "String", so the fix in the converter propagates automatically.Test plan
tests/test_date_time_arguments.py— 16 tests across 5 layers (TypeConverter, SDL, ArgumentBuilder, Introspection, E2E SQLite persistence). All green.test_argument_types.py,test_sdl_generator.py,test_introspection.py,test_query_parser.py) — 116 passed, no regressions.🤖 Generated with Claude Code