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§

Create a new instance of ObjectDef with a name.

Set the input object type as an extension

Set the InputObjectDef’s description field.

Push a Field to InputObjectDef’s fields vector.

Add a directive.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more

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.

The type returned in the event of a conversion 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.

The type returned in the event of a conversion error.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.