fix(graphql): UUID/DateTime/Date/Time as first-class scalars (6.1.0) - #306
Merged
Conversation
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>
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.
Port of nexusx #104 / #92 / #105.
uuid.UUID,datetime,date,timeall fell back toString— the scalar map only knewint/str/float/boolandmap_scalar_typeused fragile substring matching.Root cause (verified on master)
id: UUID→id: String!,created_at: datetime→String!,d: date→String!,t: time→String!Int/Float/String/Boolean/ID—UUID/DateTime/Date/Timemissing, so GraphiQL couldn't discover themlist[UUID]/list[datetime]/ single@query/@mutationparams arrived as rawstr→ crashes SQLAlchemy/SQLModel on UUID/datetime column bindingFix
type_mapping.py: subclass-matchedUUID/datetime/time/date(datetime ordered before date) → SDL + introspection field type-refs renderUUID!/DateTime!/Date!/Time!type_registry.py: register the 4 scalars inSCALAR_TYPES; deriveTypeRegistry._scalarsfrom it (kills the two-list drift)introspection_generator.py: advertise everySCALAR_TYPESentry (was a hardcoded 5-name list)executor.py:_convert_scalar_value/_coerce_scalarcoerce these args from string to the real object, recursing throughlist[T],Optional[T],Optional[list[T]]Verification
list[UUID]→[UUID],list[datetime]→[datetime], singleUUID/date/time→real objects,Optional[list[UUID]]→[UUID]✅tests/graphql/: 252 passed (was 248, +4). Tightenedtest_datetime_support(pinned scalar names, realUUIDtype, dropped the permissiveStringOR) + addedlist[UUID]/list[datetime]/single-scalar arg-conversion regressions + introspection-advertising checktests/ + demo/: 905 passed, 1 skippedruff: cleanNot bugs (verified — not ported)
has_moreoff-by-one (nexusx add schema_config #86) → PR doesn't compute it (userpage_loaderowns it)limit/offseton paginated fields (remove ensure_type #98) → PR already has itVersion
6.1.0 (minor) — SDL surface change: fields/args of these types change
String→UUID/DateTime/Date/Time. Transport unchanged. SDL consumers (codegen/Apollo) should regenerate.Decimalunchanged. Bumpspyproject.toml+uv.lock+ changelog; publish viav6.1.0tag after merge.🤖 Generated with Claude Code