pub struct InputObjectDefinition { /* private fields */ }
Expand description

Input objects are composite types used as inputs into queries defined as a list of named input values..

InputObjectTypeDefinition Description? input Name Directives? FieldsDefinition?

Detailed documentation can be found in GraphQL spec.

Example

use apollo_encoder::{Type_, InputField, InputObjectDefinition};
use indoc::indoc;

let ty_1 = Type_::NamedType {
    name: "DanglerPoleToys".to_string(),
};

let ty_2 = Type_::List { ty: Box::new(ty_1) };
let mut field = InputField::new("toys".to_string(), ty_2);
field.default_value("\"Cat Dangler Pole Bird\"".to_string());
let ty_3 = Type_::NamedType {
    name: "FavouriteSpots".to_string(),
};
let mut field_2 = InputField::new("playSpot".to_string(), ty_3);
field_2.description("Best playime spots, e.g. tree, bed.".to_string());

let mut input_def = InputObjectDefinition::new("PlayTime".to_string());
input_def.field(field);
input_def.field(field_2);
input_def.description("Cat playtime input".to_string());

assert_eq!(
    input_def.to_string(),
    indoc! { r#"
        "Cat playtime input"
        input PlayTime {
          toys: [DanglerPoleToys] = "Cat Dangler Pole Bird"
          "Best playime spots, e.g. tree, bed."
          playSpot: FavouriteSpots
        }
    "#}
);

Implementations§

source§

impl InputObjectDefinition

source

pub fn new(name: String) -> Self

Create a new instance of ObjectDef with a name.

source

pub fn extend(&mut self)

Set the input object type as an extension

source

pub fn description(&mut self, description: String)

Set the InputObjectDef’s description field.

source

pub fn field(&mut self, field: InputField)

Push a Field to InputObjectDef’s fields vector.

source

pub fn directive(&mut self, directive: Directive)

Add a directive.

Trait Implementations§

source§

impl Clone for InputObjectDefinition

source§

fn clone(&self) -> InputObjectDefinition

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for InputObjectDefinition

source§

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

Formats the value using the given formatter. Read more
source§

impl Display for InputObjectDefinition

source§

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

Formats the value using the given formatter. Read more
source§

impl TryFrom<InputObjectTypeDefinition> for InputObjectDefinition

source§

fn try_from(node: InputObjectTypeDefinition) -> Result<Self, Self::Error>

Create an apollo-encoder node from an apollo-parser one.

Errors

This returns an error if the apollo-parser tree is not valid. The error doesn’t have much context due to TryFrom API constraints: validate the parse tree before using TryFrom if granular errors are important to you.

§

type Error = FromError

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

impl TryFrom<InputObjectTypeExtension> for InputObjectDefinition

source§

fn try_from(node: InputObjectTypeExtension) -> Result<Self, Self::Error>

Create an apollo-encoder node from an apollo-parser one.

Errors

This returns an error if the apollo-parser tree is not valid. The error doesn’t have much context due to TryFrom API constraints: validate the parse tree before using TryFrom if granular errors are important to you.

§

type Error = FromError

The type returned in the event of a conversion error.

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> 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,

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.