Skip to content

Add simple type components (Enum, Scalar, Union) with component tests#79

Draft
FionaBronwen wants to merge 2 commits intofionabronwen/graphql-foundation-skeletonfrom
fionabronwen/graphql-components-1
Draft

Add simple type components (Enum, Scalar, Union) with component tests#79
FionaBronwen wants to merge 2 commits intofionabronwen/graphql-foundation-skeletonfrom
fionabronwen/graphql-components-1

Conversation

@FionaBronwen
Copy link
Copy Markdown

@FionaBronwen FionaBronwen commented Apr 12, 2026

Summary

Adds the first set of Alloy JSX type components and establishes the component testing pattern.

  • Components: EnumType, ScalarType, UnionType — these are self-contained (no Field children), making them the simplest starting point.
  • GraphQLSchema wrapper: Root component that provides TspContext and GraphQLSchemaContext to all child components.
  • Test infrastructure: renderComponentToSDL() helper renders components through the real Alloy pipeline (renderSchemaprintSchema) without file I/O or the full emitter orchestration.
  • 14 new tests covering basic rendering, doc comments, deprecation, name sanitization, @specifiedBy, union member types, and scalar wrapper variants.

Test plan

  • npm run build succeeds
  • npm test — 148 tests pass (134 existing + 14 new)

@FionaBronwen FionaBronwen force-pushed the fionabronwen/graphql-delete-legacy-v2 branch from c664ca3 to 9d65cbe Compare April 13, 2026 00:10
@FionaBronwen FionaBronwen force-pushed the fionabronwen/graphql-components-1 branch from d5eb811 to 9ce5acc Compare April 13, 2026 00:10
@FionaBronwen FionaBronwen force-pushed the fionabronwen/graphql-delete-legacy-v2 branch from 9d65cbe to 48403d0 Compare April 14, 2026 21:56
@FionaBronwen FionaBronwen force-pushed the fionabronwen/graphql-components-1 branch from 9ce5acc to e8903e3 Compare April 14, 2026 21:56
@FionaBronwen FionaBronwen force-pushed the fionabronwen/graphql-delete-legacy-v2 branch from 48403d0 to 806adc8 Compare April 14, 2026 22:06
@FionaBronwen FionaBronwen force-pushed the fionabronwen/graphql-components-1 branch 3 times, most recently from f379460 to c9c7af2 Compare April 21, 2026 16:26
@FionaBronwen FionaBronwen changed the base branch from fionabronwen/graphql-delete-legacy-v2 to fionabronwen/graphql-foundation-skeleton April 21, 2026 16:26
@FionaBronwen FionaBronwen force-pushed the fionabronwen/graphql-foundation-skeleton branch from ce78164 to 5c566f6 Compare April 21, 2026 20:25
@FionaBronwen FionaBronwen force-pushed the fionabronwen/graphql-components-1 branch from c9c7af2 to 4178df3 Compare April 21, 2026 20:25
@FionaBronwen FionaBronwen force-pushed the fionabronwen/graphql-foundation-skeleton branch from 5c566f6 to c6906db Compare April 21, 2026 20:43
@FionaBronwen FionaBronwen force-pushed the fionabronwen/graphql-components-1 branch from 4178df3 to 5195591 Compare April 21, 2026 20:43
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
@FionaBronwen FionaBronwen force-pushed the fionabronwen/graphql-components-1 branch from 5195591 to c288111 Compare April 22, 2026 17:09
@FionaBronwen FionaBronwen force-pushed the fionabronwen/graphql-foundation-skeleton branch from 193c59a to 95f3757 Compare April 22, 2026 17:09
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