Architecture decision record · ADR-0017
Codegen normalizers for REST and GraphQL wires
For each contract that is not JSON:API, codegen writes a data map: for each entity, its resource type, its id field, its attributes and its relationships.
Context
WarpDrive's cache reads JSON:API documents. A plain REST or GraphQL response is not one, so the generated schemas alone do not load it.
Decision drivers
Not recorded in the original ADR.
Options considered
Not recorded in the original ADR.
Decision
- For each contract that is not JSON:API, codegen writes a data map: for each entity, its resource type, its id field, its attributes and its relationships.
@millwork-ts/contracthas one walker,toJsonApi(map, type, body). It walks a response body with the map, finds each entity by its id, and gives a JSON:API document withdataandincluded. A nested entity becomes a relationship and anincludedmember.- Codegen writes a RequestManager handler,
contractHandler, that calls the walker for each request that hasoptions.contractwith the response type. - A JSON:API contract needs no normalizer.
Consequences
- The generated part is data only. A fix to the walker fixes every app.
- A response that does not hold the entities in a known place needs a mark in the contract.
Confirmation
Not recorded in the original ADR.
Interview record
Each question of the interview with its answer and its source. A fact from the code or a document, a question that the author did not ask, and an assumption are rows too.
| Question | Answer | Source |
|---|---|---|
| Where does the text of this page come from? | From the Markdown file docs/adr/0017-normalizers.md at commit c8154b0. The text of each section is the text of the Markdown file. A section that the Markdown file does not have says so. | Document: docs/adr/0017-normalizers.md |
Changelog
| Date | Author | Change |
|---|---|---|
| 2026-12-03 | Joe Gaudet | Status in the Markdown file: Accepted (codegen C0). |
| 2026-12-03 | Joe Gaudet | Commit 7b66d71: Add codegen: one contract gives WarpDrive, Millwork, real-enums, Formwright and harnessed code (#7) |
| 2026-12-04 | Joe Gaudet (agent) | Converted from docs/adr/0017-normalizers.md to this page. The text is the text of the Markdown file. |
The adr skill of skillsaw wrote this page. The HTML in this file is the source of truth. The diagrams are the Mermaid sources in it.