Skip to main content

UnionSkin

Struct UnionSkin 

Source
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: GraphqlKind

Which 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

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for UnionSkin

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UnionSkin

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.