15.1 How it fits together
web/src/graphql/*.graphql ──┐
├──► trax client ──► web/src/trax/ (typed functions, hooks)
hub --trax-export-client ───┘ └── trax.documents.json ──► the hub registers it- The page writes its documents, one operation per
.graphqlfile, asking for exactly the fields it shows. - The hub exports its client manifest: every train, query model and machine it serves, with their types. The hub writes it and exits, without serving.
trax clientreads both and writes the client: a function per document, and the documents themselves intrax.documents.json.- The hub registers
trax.documents.jsonwhen it starts. Each document gets an id from a hash of its text, and the page sends only that id and its variables, never the text. That is what persisted operations are: the server runs the documents it registered, and in chapter 17 it runs nothing else.
A document that asks for a field the hub does not serve, or one a train refuses, stops the hub at start, naming the document and its file. A mistake in the storefront is found when the hub starts, not when a customer clicks.
SDK Reference
Generated clients | trax client | Client manifest | Fetch only what a component needs | Run progress