Expand description
THE MUTATION NODE’s model — the command vocabulary a source is controlled through, and the record a source’s own expansion reads that declaration through. The MUTATION NODE’s model and its DECLARATION-SIDE emission: the command vocabulary a source is controlled through, and the record a source’s own expansion reads that declaration through.
#[ingraph::mutation(graphql(async_graphql))]
pub struct WatchOps {
#[ingraph(rename = "addWatch",
handler(path = "crate::watch::add", async,
context(resource("crate::Catalog")),
error(type = "crate::AddWatchError", code = "ADD_FAILED")))]
add: (AddWatch, AddResponse),
#[ingraph(handler = "crate::watch::reindex")]
reindex: (Reindex, ()),
}§FIELDS ARE EXCHANGES, which is why there is no list to write
One field is one thing an app can say. The field’s TYPE answers what that exchange IS — a
request, a response, a failure — through Mutation, and the words beside the field answer
everything a type cannot: who runs it, what the wire calls it, what it was handed, how it fails.
So the declaration has no second list of commands anywhere; a vocabulary that could disagree with
the fields would be a vocabulary two readings could differ about.
§WHAT IS EMITTED HERE, and what waits
Six items always, and each answers a reader the others cannot:
| item | who reads it |
|---|---|
<Node>Command | the source’s own run body, matching on what an app said |
impl MutationNode for <Node> | the Control line’s type, through the source’s Mutation seat |
impl DeclaredMutation for <Node> | everybody who cannot see these tokens |
<Node>Response / <Node>Error | whatever calls the assembled face |
<Node>::handle_<node> | a first-party transport, a test, the source-side caller |
And, where the declaration wore a graphql(…) word, the WIRE FACE over all of it — the unit a
root folds, and one resolver per exchange. [wire] is where that lives and where its own rules
are written; [face] is where the assembled one does. What is worth knowing here is that
everything above is emitted either way, so a node with no wire word still has its whole Rust
surface — and that the wire and the face SHARE one call per exchange, which is the one place a
handler’s declared signature is cast.
§The declaration record is a RECORD and not a channel
DeclaredMutation’s table restates what these tokens already say, and that is deliberate:
Declared‘s own note gives the reason one layer over, which is that two expansions cannot read
each other’s tokens. A source declaring mutation(node = "WatchOps") expands in a pass that has
never seen WatchOps’ fields, so what crosses is a trait impl and a projection off it — nobody
reads anybody’s tokens and the compiler resolves the meeting.
Structs§
- Exchange
Model - ONE field of a mutation node: the exchange, and the words written beside it.
- Handler
Model - The
handler(…)block: the three segments of a signature. - Mutation
Model - A validated mutation declaration, ready to emit.
Enums§
- Declared
Error - The
error(…)word’s two legal shapes, each optionally headed by a code.