Add integration test suite for GraphQL emitter#85
Open
FionaBronwen wants to merge 32 commits into
Open
Conversation
2 tasks
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-operations-wiring
branch
from
April 21, 2026 20:25
0b4cb8e to
3387127
Compare
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-test-suite
branch
2 times, most recently
from
April 21, 2026 20:33
157c423 to
6574167
Compare
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-operations-wiring
branch
from
April 21, 2026 20:33
3387127 to
1a5163c
Compare
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-test-suite
branch
from
April 21, 2026 20:43
6574167 to
f3179e4
Compare
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-operations-wiring
branch
2 times, most recently
from
April 22, 2026 17:09
9e90b36 to
ffc3f0f
Compare
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-test-suite
branch
2 times, most recently
from
April 28, 2026 15:13
cda60b4 to
6211400
Compare
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-operations-wiring
branch
from
April 28, 2026 15:13
ffc3f0f to
2763d30
Compare
Introduce the foundation for the component-based GraphQL emitter: - Build/config: Add @alloy-js/core, @alloy-js/graphql dependencies, configure JSX transpilation (tsconfig, vitest) - Context system: GraphQLSchemaContext with ClassifiedTypes, ModelVariants, and ScalarVariant interfaces - Field components: Field, OperationField, and GraphQLTypeExpression for rendering model properties and operations as GraphQL SDL - Type resolution: GraphQLTypeExpression handles scalars, models, enums, unions, arrays, and nullability using an isInput prop to distinguish input vs output context - Scalar mappings: Add getGraphQLBuiltinName() for built-in scalar identity checks
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-operations-wiring
branch
from
April 28, 2026 15:28
2763d30 to
f73791c
Compare
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-test-suite
branch
from
April 28, 2026 15:28
6211400 to
159673e
Compare
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-operations-wiring
branch
from
April 28, 2026 15:55
f73791c to
ce4affb
Compare
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-test-suite
branch
2 times, most recently
from
April 28, 2026 21:21
3f5da2b to
7db97d1
Compare
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-operations-wiring
branch
2 times, most recently
from
April 30, 2026 21:10
98fb4f4 to
eb57da4
Compare
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-test-suite
branch
from
April 30, 2026 21:10
7db97d1 to
0fa84c0
Compare
The ModelVariants lookup structure was originally designed to help components decide when to append "Input" suffix to model names. However, the mutation engine now fully handles this: - Input models are mutated with the "Input" suffix already applied - Property type references are rewired to point to the correct variants This commit removes the unused ModelVariants interface and the lookup logic from GraphQLTypeExpression, simplifying the component to just use the model's name directly. Also adds unionMembers to context (needed for union rendering).
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-operations-wiring
branch
from
May 1, 2026 15:17
eb57da4 to
2be2c50
Compare
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-test-suite
branch
from
May 1, 2026 15:17
0fa84c0 to
ff55993
Compare
Remove unused utility functions that were superseded by the mutation engine: - getTemplatedModelName (mutation engine handles template naming) - getSingleNameWithNamespace (never used in production) - isArray, isRecordType, isScalarOrEnumArray, isUnionArray (use compiler's isArrayModelType) - unwrapModel, unwrapType (never imported) - isTrueModel (never imported) Also removes the corresponding test for getSingleNameWithNamespace.
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-operations-wiring
branch
from
May 1, 2026 15:33
2be2c50 to
c975212
Compare
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-test-suite
branch
from
May 1, 2026 15:33
ff55993 to
e106d87
Compare
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-operations-wiring
branch
2 times, most recently
from
May 1, 2026 20:04
918f6cc to
cf1eb14
Compare
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-test-suite
branch
from
May 5, 2026 15:40
e106d87 to
bc9c39c
Compare
Add the first set of Alloy JSX components for GraphQL type emission: - EnumType: renders GraphQL enum definitions with member descriptions and deprecation - ScalarType: renders custom scalar definitions with @specifiedBy support - UnionType: renders union type definitions with model and scalar variant members - GraphQLSchema: root context wrapper providing TspContext and GraphQLSchemaContext Add component-level tests using renderSchema + printSchema to exercise the real Alloy rendering pipeline. Each component is tested in isolation with a lightweight test helper (renderComponentToSDL) that provides minimal context. 14 new tests covering: basic rendering, doc comments, deprecation, name sanitization, @specifiedBy, union member registration, and scalar wrappers.
- Extract isScalarLikeType() to type-utils.ts shared utility, replacing duplicated inline check in union-type.tsx - Replace unsafe `as Union` casts in union-type tests with assertUnionResult() helper that provides a clear error if the mutation returns a Model
Replace fragile .toContain() assertions with inline snapshots to match TSP ecosystem best practices. This makes test output more readable and maintainable by showing the complete expected SDL in one place.
The function was extracted from union-type.tsx in commit 6d47132e4 but the type-utils.ts hunk was dropped during the rebase due to conflicts with 'Remove dead code from type-utils.ts' in the base.
- ScalarType: take specificationUrl as prop instead of from context - component-test-utils: use minimal TypeGraph context - scalar-type.test: pass specificationUrl as prop
- Mutate operations in schema-mutator so type references point to correctly mutated types (input params → mutated input models, return types → mutated output models) - Fix nullable union replacement to mutate inner type with context (Address | null → AddressInput in input context) - Add Input suffix to models in input context with double-suffix prevention (BookInput stays BookInput, not BookInputInput) - Add comprehensive tests for input suffix, nullable union replacement, and operation type references
Models used as both input and output must be mutated separately: - Output context produces 'Foo' - Input context produces 'FooInput' Previously, all models were mutated with Output context only, causing duplicate type names when rendering both variants.
- Add withInputSuffix helper to prevent "PetInput" → "PetInputInput" - Fix oneOf input unions to mutate variant types with input context (model variants now correctly get their Input suffix, e.g. Cat → CatInput) - Refactor model.ts to use shared withInputSuffix helper
Add field-bearing type components that use the Field infrastructure (already present from the parent branch): - ObjectType: renders object types with fields, @compose interfaces, and @operationFields support - InterfaceType: renders interface type definitions with fields - InputType: renders input types with automatic Input suffix when a model appears in both input and output positions 17 new component tests covering: basic field rendering, doc comments, optional/nullable fields, array/list types, deprecated fields, interface implementation via @compose, and Input suffix logic.
…ed imports - Add explanatory comment on getComposition/iface.name in object-type.tsx clarifying that pre-mutation names match post-mutation names (mutation engine doesn't rename models) - Remove unused `type Model` import from all G2 test files
- Add @operationFields test to ObjectType (verifies operation field rendering) - Add nested model reference test to ObjectType (verifies type references) - Add empty model tests to ObjectType, InputType, InterfaceType (documents that GraphQL requires at least one field per type)
The mutation engine now handles all input/output type naming, so components can use type.name directly without looking up whether a model has both input and output variants.
- Remove implementation detail comments about mutation engine - Remove redundant tests that were testing non-responsibility of the component (InputType doesn't add suffixes - that's not its job)
Replace fragile .toContain() assertions with inline snapshots to match TSP ecosystem best practices. This makes test output more readable and maintainable by showing the complete expected SDL in one place.
Brings the component-based GraphQL emitter online by wiring the data pipeline from the foundation skeleton into Alloy JSX rendering. New components: - components/operations/query-type.tsx, mutation-type.tsx, subscription-type.tsx: render the three GraphQL root operation types - components/operations/index.ts: barrel export - components/type-collections.tsx: orchestrator that dispatches each classified-type bucket (scalars, enums, unions, interfaces, objects, inputs) into the appropriate leaf-type component Emitter wiring: - Rename src/emitter.ts → src/emitter.tsx - Phase 5 now renders via Alloy's renderSchema, converts to SDL with graphql-js printSchema, and writes the output via emitFile - Adds output-file option handling with interpolatePath Testing: - test/e2e.test.ts: single happy-path smoke test proving the full TypeSpec → mutation → classification → rendering → SDL pipeline works - Update the existing test/emitter.test.ts data-pipeline test to now assert that SDL output is produced (Phase 5 is wired up) Broader integration coverage (nullability, input/output splitting, unions, enums, arrays, circular refs, deprecation, doc comments) lands in a follow-up PR focused on tests.
Adds component tests for QueryType, MutationType, and SubscriptionType using inline snapshots. Tests cover rendering with scalar return types, model return types (with stub type registration), parameters, and empty operation lists. Updates renderComponentToSDL utility to support skipPlaceholderQuery option for testing QueryType, while maintaining backwards compatibility with existing tests that pass context overrides directly. Also cleans up e2e and emitter tests to use consistent vitest expect() assertions with toMatchInlineSnapshot() instead of mixed strictEqual and .includes() checks.
- type-collections: components take data via props instead of context - emitter: pass MutatedSchema data directly to collection components - Use minimal TypeGraph context (just globalNamespace) This aligns with the TypeGraph design where context is minimal and components receive their data through props.
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-operations-wiring
branch
from
June 3, 2026 20:01
8ac0071 to
c42edc5
Compare
Expands the test coverage of the component-based emitter to exercise the full surface area of TypeSpec-to-GraphQL translation. New test files: - nullability.test.ts: required vs. optional vs. T | null, input and output side semantics, list element nullability - input-output-splitting.test.ts: models used as input, output, or both; verifies correct suffixing and separation - unions.test.ts: named union types, nullable variants, wrapper models - enums.test.ts: enum declarations, enum values, enum references in model properties and operations - arrays.test.ts: array element non-null semantics and nested arrays - circular-references.test.ts: self-referential and mutually recursive model definitions - deprecation.test.ts: @deprecated decorator propagation to SDL - doc-comments.test.ts: doc-comment propagation to SDL descriptions Extends e2e.test.ts beyond the single smoke test into a full scenario suite (complete API schema, custom scalars, union output types, models used only as input, mutations, empty schema handling, operation parameters, and complex SDL validation). Extends test/main.tsp with the fixture models, operations, and helpers needed by the e2e and integration tests. No production code changes — this PR is tests only.
… diagnostics - subscriptions.test.ts: 5 tests for subscription operations with arguments, arrays, and complex input types - interfaces-sdl.test.ts: 6 tests for interface type declarations, multiple interface implementations, interface inheritance, and optional fields - operation-fields-sdl.test.ts: 5 tests for @operationFields decorator SDL output including field arguments and interface operations - diagnostics.test.ts: 12 tests for emitter diagnostics including empty-schema, void-operation-return, duplicate union variants, interface validation errors, and operation-kind conflicts
Updated snapshot expectations to reflect correct behavior where optional fields (?) are nullable in both input and output contexts. Also skipped union-within-union test that crashes in Alloy (pre-existing bug).
FionaBronwen
force-pushed
the
fionabronwen/graphql-components-test-suite
branch
from
June 3, 2026 20:15
ea9883d to
8b368d5
Compare
FionaBronwen
changed the base branch from
fionabronwen/graphql-components-operations-wiring
to
feature/graphql
June 9, 2026 21:04
FionaBronwen
force-pushed
the
feature/graphql
branch
2 times, most recently
from
June 16, 2026 22:19
59ad903 to
7d69aac
Compare
FionaBronwen
force-pushed
the
feature/graphql
branch
from
June 23, 2026 23:17
e9dad03 to
954e220
Compare
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
Adds a comprehensive test suite for the GraphQL emitter.
Test coverage: 288 tests across 29 test files
Integration Tests
e2e.test.tsscalars.test.ts@specifiedBydirectivesenums.test.tsunions.test.tsnullability.test.tsinput-output-splitting.test.tsdoc-comments.test.tssubscriptions.test.tsinterfaces-sdl.test.tsoperation-fields-sdl.test.ts@operationFieldsdecorator outputdiagnostics.test.tsComponent Unit Tests
scalar-type.test.tsxenum-type.test.tsxunion-type.test.tsxobject-type.test.tsxinterface-type.test.tsxinput-type.test.tsxoperation-types.test.tsxOther Tests
graphql-mutation-engine.test.ts(80 tests) - Mutation engine transformationsTest plan