pub struct UnionSkin {
pub kind: GraphqlKind,
pub output: Option<UnionOutput>,
pub input: Option<UnionInput>,
}Expand description
ONE GraphQL backend’s rendering of a declared union — which of the two schema positions it is dressed for.
The pair is the whole vocabulary and neither is implied by the other: a union declared for input
alone is an @oneOf argument object nothing returns, and one declared for output alone is a
result type no argument takes. A backend named with NEITHER word is refused at the declaration —
a block that dresses no position dresses nothing.
Fields§
§kind: GraphqlKindWhich backend this is.
output: Option<UnionOutput>output — the schema’s union X = A | B, in a RETURN position.
input: Option<UnionInput>input — the schema’s @oneOf input object, in an ARGUMENT position.
Implementations§
Source§impl UnionSkin
impl UnionSkin
Sourcepub fn output_sdl(&self, base: &Ident) -> String
pub fn output_sdl(&self, base: &Ident) -> String
What a schema calls this union’s OUTPUT face — output(rename = "…"), else the enum’s own name
unraw’d.
The default is input_sdl’s law read from the other side: where both faces
are rendered the output is the one that keeps the union’s own word, because it is the one a
client names in a selection set. The knob moves that word without touching the law — and it
moves the twin with it.
Sourcepub fn input_sdl(&self, base: &Ident) -> String
pub fn input_sdl(&self, base: &Ident) -> String
What a schema calls this union’s INPUT face.
§The naming law, whole
Both faces are impls on ONE Rust type, and a GraphQL schema has ONE namespace for type names. So:
- a union rendering ONE face — either one — publishes it under the union’s own name, there being nothing else to collide with;
- a union rendering BOTH gives the union’s own name to the OUTPUT and derives the input’s by suffixing it, because the output type is the one a client names in a selection set and an argument object is the derived twin of it.
input(rename = "…") moves this word and only this word, at either arity: a declaration whose
scope already publishes a <Union>Input needs the escape as much as one that simply prefers
another name.
§The derived twin follows the OUTPUT’s word, not the Rust ident
output(rename = "Sighting") on a both-faces union publishes Sighting and SightingInput,
which is the ONE BLESSED DERIVATION the rename laws name — the same composition
key(rename = "Address") spends to publish Address and AddressInput. Composing off the Rust
ident instead would publish the renamed union beside an input object still wearing the old
stem: a rename that moved one face and not the other, which the naming law calls worse than
none.