Replace legacy emitter with foundation skeleton and diagnostics#83
Open
FionaBronwen wants to merge 2 commits intofionabronwen/graphql-alloy-foundation-v2from
Open
Conversation
8b51ca4 to
8f411e1
Compare
afdf684 to
ce78164
Compare
2 tasks
ce78164 to
5c566f6
Compare
Removes the procedural GraphQL emitter and stands up the data-pipeline skeleton that the upcoming Alloy component-based emitter will build on. Deleted: - graphql-emitter.ts (old procedural emitter) - schema-emitter.ts (old schema-specific emitter) - registry.ts (old type registry) - type-maps.ts (old type mapping logic) - test/emitter.test.ts tests for the legacy emitter Rewrote src/emitter.ts as a four-phase data pipeline: - Phase 1: type usage tracking (reachability / input-output marking) - Phase 2: mutation (GraphQL naming via the mutation engine) - Phase 3: classification (interfaces, output models, input models, ops) - Phase 4: model variant lookups The pipeline produces a SchemaPipelineResult bundle (classifiedTypes, modelVariants, scalarSpecifications) that is handed to a renderSchema stub. The stub is a no-op in this PR; component-based SDL rendering, file emission, and the .tsx conversion land in follow-up PRs. Introducing the SchemaPipelineResult type and the pipeline/renderer seam here keeps the downstream PR reviewable on its own. Also introduces two new diagnostics that the pipeline reports today: - empty-schema: fires when a schema has no query root (GraphQL requires one) - void-operation-return: fires when an operation returns void (no GraphQL equivalent; the operation is filtered out of the schema) Test coverage added for both diagnostics in test/emitter.test.ts.
b3a1c52 to
193c59a
Compare
The emitter used to walk the schema namespace itself, bucket types by kind, dedup scalars, and run a second classification pass to split models into input/output variants. That loop also leaked implementation details (an `originalToMutated` back-map and a `TypeUsageResolver` that outlived mutation) into the emitter's public shape. Introduce `GraphQLMutationEngine.mutateSchema(schema, typeUsage)` that returns a fully-classified `MutatedSchema`: - Pre-bucketed models: `interfaces`, `outputModels`, `inputModels` - Pre-classified operations: `queries`, `mutations`, `subscriptions` - Derived metadata: `wrapperModels`, `scalarVariants`, `scalarSpecifications` Classification happens inline during the walk. `typeUsage` is consumed entirely inside the engine; the emitter hands it over and never touches it again. `originalToMutated` no longer exists outside the engine. Implementation lives in `src/mutation-engine/schema-mutator.ts` as a free function called from the `GraphQLMutationEngine` class to avoid a circular import between engine.ts and schema-mutator.ts. The emitter's `emitSchema` reduces to: resolve type usage, call `engine.mutateSchema`, report void-return diagnostics, check for empty schema, build variant lookups, hand off to the (stubbed) renderer.
193c59a to
95f3757
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
$onEmit, and supporting files)emitter.tscovering Phases 1–4: type-usage analysis → mutation → classification → model-variant assignment.lib.ts:empty-schema(warning) — emitted when classification produces no queriesvoid-operation-return(warning) — emitted for operations that returnvoidempty-schemaguard intoemitSchemaand thevoid-operation-returnfilter intoclassifyTypesTest plan
pnpm buildsucceedspnpm test— 142 tests pass (140 baseline + 2 new diagnostic tests)empty-schemadiagnostic is emitted when no queries are classifiedvoid-operation-returndiagnostic is emitted for void operations