Skip to main content

wire_method

Function wire_method 

Source
pub fn wire_method(name: &Ident) -> Ident
Expand description

The __async_graphql_ prefix every FUNCTION an emitted #[Object] face declares wears — and every ARGUMENT such a function takes.

§The prefix names the BACKEND, and that is the ruling rather than a decoration

The user’s ruling of 2026-08-13: async-graphql 的都要加前缀,通过 rename 避免冲突,前缀用 __async_graphql_xxx 因为以后可能支持更多 graphql 后端.

So the Rust namespace is PER BACKEND. A second GraphQL binding mounted on the same emitted type mints __smear_<name> beside __async_graphql_<name> and the two cannot meet — where a shared __<name> would have made the first backend’s face the reason the second one cannot be written, reported as E0592 inside an expansion whose author cannot edit either half. The prefix is not the collision-proofing alone; it is WHOSE face this is, spelled into the ident.

The WIRE face is unmoved by any of it: the name a CLIENT reads is written beside the ident as #[graphql(name = "…")], per item and never derived from a spelling — see emit::wire’s own note — so the ident is free to carry the backend’s name and a schema cannot tell that it does.

§Why the wire face’s Rust names are ugly on purpose

A method inside #[Object] is not a Rust API: nothing outside the expansion calls it, and it is reached through the schema. So the ident is free to be defensive, and it is: the prefix puts every generated function and argument in a namespace no declaration writes — the same vaccine the emission’s own __ingraph_* locals already carry, applied at the one position that had none. emit::wire’s prelude note records what the class costs when it is not taken: a foreign macro’s bare None captured by a declarer’s struct None, reported at a #[record(…)] naming a type nobody in that file mentions.

Those LOCALS keep __ingraph_ and are not swept into the backend’s namespace, because they are a different question: a local is scoped to the body it is written in, so two backends’ bodies cannot collide however they spell theirs, and what the prefix answers there is whose crate wrote this, which is the framework’s rather than any binding’s.

TYPES take no prefix, and that is the ruled other half: <E>GraphqlOutput and <E>KeyOutput are visible vocabulary a declaration names and an application mounts, so a mangled one would be an emitter’s convention leaking into somebody else’s code.

Here rather than beside either emitter, for this module’s own reason: a derived name has ONE home, and a prefix written twice is a prefix that can be written differently. Every emitted face calls this — emit::wire‘s two objects, emit::queries’ three legs and their arguments, interface::queries’ leg — so a change to the shape moves all of them at once, which is what made this sweep a one-line edit under a walk rather than a rename across the corpus.