Add GraphQL mutation engine for TSP type transformations #56
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
This PR introduces a GraphQL mutation engine that leverages the
@typespec/mutator-frameworkto transform TypeSpec types for GraphQL schema generation. This PR establishes the foundation with name sanitization, but the architecture will support additional transformations (e.g., input/output type splitting, visibility filtering) in future PRs.What it does
The mutation engine wraps the
mutator-framework'sMutationEnginewith GraphQL-specific mutation classes. These classes intercept type graph traversal to apply GraphQL-specific transformations.Current transformation: Name sanitization ensures all type, field, and member names are valid GraphQL identifiers (e.g.,
$Invalid$→_Invalid_,my-field→my_field).Future transformations (not in this PR):
Architecture
GraphQLMutationEngineMutationEngineGraphQLEnumMutationGraphQLEnumMemberMutationGraphQLModelMutationGraphQLModelPropertyMutationGraphQLOperationMutationGraphQLScalarMutationChanges
New Files:
src/mutation-engine/engine.ts- Core engine wrappingMutationEnginesrc/mutation-engine/options.ts- GraphQL-specific mutation optionssrc/mutation-engine/mutations/*.ts- 6 mutation classes for different type kindstest/mutation-engine/graphql-mutation-engine.test.ts- unit testsUsage