Struct apollo_encoder::InputObjectDefinition
source · [−]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(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 = InputObjectDefinition::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
sourceimpl InputObjectDefinition
impl InputObjectDefinition
sourcepub fn description(&mut self, description: Option<String>)
pub fn description(&mut self, description: Option<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
sourceimpl Clone for InputObjectDefinition
impl Clone for InputObjectDefinition
sourcefn clone(&self) -> InputObjectDefinition
fn clone(&self) -> InputObjectDefinition
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for InputObjectDefinition
impl Debug for InputObjectDefinition
Auto Trait Implementations
impl RefUnwindSafe for InputObjectDefinition
impl Send for InputObjectDefinition
impl Sync for InputObjectDefinition
impl Unpin for InputObjectDefinition
impl UnwindSafe for InputObjectDefinition
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more