Struct apollo_encoder::InputObjectDef [−][src]
pub struct InputObjectDef { /* fields omitted */ }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.
Note: At the moment InputObjectTypeDefinition differs slightly from the
spec. Instead of accepting InputValues as field parameter, we accept
InputField.
Example
use apollo_encoder::{Type_, InputField, InputObjectDef};
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(Some("\"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(Some("Best playime spots, e.g. tree, bed.".to_string()));
let mut input_def = InputObjectDef::new("PlayTime".to_string());
input_def.field(field);
input_def.field(field_2);
input_def.description(Some("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
Set the InputObjectDef’s description field.
Push a Field to InputObjectDef’s fields vector.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for InputObjectDef
impl Send for InputObjectDef
impl Sync for InputObjectDef
impl Unpin for InputObjectDef
impl UnwindSafe for InputObjectDef
Blanket Implementations
Mutably borrows from an owned value. Read more