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.

Status
Accepted
Deciders
Joe Gaudet
Created
Updated
PRD
PRD
Related
None

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/contract has 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 with data and included. A nested entity becomes a relationship and an included member.
  • Codegen writes a RequestManager handler, contractHandler, that calls the walker for each request that has options.contract with 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.

QuestionAnswerSource
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

DateAuthorChange
2026-12-03Joe GaudetStatus in the Markdown file: Accepted (codegen C0).
2026-12-03Joe GaudetCommit 7b66d71: Add codegen: one contract gives WarpDrive, Millwork, real-enums, Formwright and harnessed code (#7)
2026-12-04Joe 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.