⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@FionaBronwen
Copy link

@FionaBronwen FionaBronwen commented Jan 5, 2026

Summary

Adds utility functions for transforming TypeSpec names into valid GraphQL identifiers. These utilities form the foundation for name handling throughout the GraphQL emitter.

Changes

  • src/lib/type-utils.ts - Core utility functions for GraphQL name transformations
  • test/lib/type-utils.test.ts - Unit tests for sanitizeNameForGraphQL

Utilities Added

Function Purpose
sanitizeNameForGraphQL Sanitize names to be valid GraphQL identifiers
toTypeName Convert to PascalCase for type names
toFieldName Convert to camelCase for field names
toEnumMemberName Convert to CONSTANT_CASE for enum members
getUnionName Generate names for anonymous unions
getTemplatedModelName Generate names for templated models (e.g., ListOfString)
isArray, isRecordType Type guards for array/record models
unwrapModel, unwrapType Extract element types from arrays
isTrueModel Check if a model should emit as GraphQL object type
getGraphQLDoc Extract doc comments for GraphQL descriptions

@FionaBronwen FionaBronwen force-pushed the fionabronwen/type-utils branch 4 times, most recently from 65f55e7 to 0bc74f1 Compare January 7, 2026 19:59
@FionaBronwen FionaBronwen marked this pull request as ready for review January 7, 2026 20:03
@FionaBronwen FionaBronwen removed the request for review from swatkatz January 7, 2026 20:03
@FionaBronwen FionaBronwen force-pushed the fionabronwen/type-utils branch 2 times, most recently from 894989c to 8dbe441 Compare January 15, 2026 19:10
/** Generate a string representation of template arguments (e.g., `StringAndInt`). */
export function getTemplateString(
type: Type,
options: { conjunction: string } = { conjunction: "And" },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we actually using this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's used to construct Union names and templated model names!

@FionaBronwen FionaBronwen force-pushed the fionabronwen/type-utils branch from 8dbe441 to f5fca8d Compare January 15, 2026 19:49
@FionaBronwen FionaBronwen merged commit 42df8a9 into feature/graphql Jan 15, 2026
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.

3 participants