feat: #30 generate client types from the GraphQL schema #75
+2,380
−253
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.
Closes #30.
What was done
client/src/types.tsno longer exists (it was removed before M3), so the issue text was stale. The real problem was the same one it described: every result type was hand-written next to its operation, with nothing tying it toschema.graphql. That is how theGenreFacet.genreshape was wrong in M2.client/codegen.tsruns the GraphQL Code Generator client preset against the repository's rootschema.graphql- the same file the server reads at startup, so there is no second copy of the contract.client/src/api/*.tsbut is declared withgraphql(). Result types are derived (SearchAlbumsQuery['searchAlbums'],NonNullable<AlbumDetailQuery['album']>, ...), and the component-facing names (AlbumSummary,GenreFacet,AlbumDetail) survive as aliases, so this PR does not touch components - deliberately, to keep it mergeable with Improve UI to match the original design specification #70.DateTimeis mapped tostring; without it the generated type isunknownand the review timestamps stop typechecking.client/src/generated/, and CI regenerates and fails on any diff before typecheck runs, so the message is "run pnpm codegen" rather than a type error inside generated code.CrateButton.test.tsx's fixture operation lands in the generated document map and in the production bundle.ALBUM_SORTSstays a runtime array (the URL parser iterates it; the generated enum is a type union with nothing to iterate), and a new test compares it to the schema enum so a value cannot go missing.pnpm buildruns the generator first, which is what makes the acceptance criterion literally true.What was tested
The acceptance criterion, run for real. Renaming
averageRatingtoaverageScoreinschema.graphql:Restored,
pnpm buildsucceeds:index-*.js 418.29 kB (gzip 126.37 kB), inside the 512 000-byte budget.pnpm format:check && pnpm lint && pnpm typecheck && pnpm testpasses: 108 client tests (one new), 61 server tests.pnpm codegenimmediately after generation produces no diff, which is what the CI step checks.Notes for the reviewer
client/:@graphql-codegen/cli,@graphql-codegen/client-preset, plus@graphql-typed-document-node/corewhich the preset's output imports and pnpm does not hoist.