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
impl InputObjectDefinition
Sourcepub fn description(&mut self, description: String)
pub fn description(&mut self, description: String)
Set the InputObjectDef’s description field.
Sourcepub fn field(&mut self, field: InputField)
pub fn field(&mut self, field: InputField)
Push a Field to InputObjectDef’s fields vector.
Trait Implementations§
Source§impl Clone for InputObjectDefinition
impl Clone for InputObjectDefinition
Source§impl Debug for InputObjectDefinition
impl Debug for InputObjectDefinition
Source§impl Display for InputObjectDefinition
impl Display for InputObjectDefinition
Source§impl TryFrom<InputObjectTypeDefinition> for InputObjectDefinition
impl TryFrom<InputObjectTypeDefinition> for InputObjectDefinition
Source§fn try_from(node: InputObjectTypeDefinition) -> Result<Self, Self::Error>
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.
Source§impl TryFrom<InputObjectTypeExtension> for InputObjectDefinition
impl TryFrom<InputObjectTypeExtension> for InputObjectDefinition
Source§fn try_from(node: InputObjectTypeExtension) -> Result<Self, Self::Error>
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.