Skip to content

Guard GraphQL built-in scalars from incorrect mutation renaming#70

Open
FionaBronwen wants to merge 1 commit intofionabronwen/graphql-scalar-idfrom
fionabronwen/graphql-scalar-builtin-guard
Open

Guard GraphQL built-in scalars from incorrect mutation renaming#70
FionaBronwen wants to merge 1 commit intofionabronwen/graphql-scalar-idfrom
fionabronwen/graphql-scalar-builtin-guard

Conversation

@FionaBronwen
Copy link

Summary

  • Add isGraphQLBuiltinScalar() guard to prevent TypeSpec built-in scalars (string, boolean, int32, float32, float64) from being incorrectly renamed by the scalar mutation engine when they inherit a mapping from an ancestor in the extends chain (e.g., float32floatnumericNumeric)
  • Uses identity-based check via typekit (isStdScalar + name lookup) to avoid false positives from user-defined scalars
    that share a built-in name in a different namespace
  • Prevents float32 from being renamed to Numeric due to getScalarMapping walking the extends chain to numeric, which has a mapping entry. GraphQL's Float is IEEE 754 double-precision, so both float32 and float64 map to it natively — no custom scalar needed.

Test plan

Added the following unit tests:

  • float32 is not renamed despite inheriting Numeric mapping from numeric ancestor
  • float64 is not renamed (also maps to GraphQL Float)
  • int32 is not renamed (maps to GraphQL Int)
  • int64 is still correctly renamed to Long (not a GraphQL built-in)

All 110 tests pass

@FionaBronwen FionaBronwen marked this pull request as ready for review March 12, 2026 19:54
@FionaBronwen FionaBronwen removed the request for review from swatkatz March 12, 2026 19:54
@FionaBronwen FionaBronwen force-pushed the fionabronwen/graphql-scalar-builtin-guard branch from 134b92a to 397b7e5 Compare March 13, 2026 18:55
@FionaBronwen FionaBronwen force-pushed the fionabronwen/graphql-scalar-id branch from 82569eb to 621c9a7 Compare March 13, 2026 18:55
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