Struct apollo_encoder::FragmentDefinition
source · [−]pub struct FragmentDefinition { /* private fields */ }
Expand description
The FragmentDefinition type represents a fragment definition
FragmentDefinition: fragment FragmentName TypeCondition Directives? SelectionSet
Detailed documentation can be found in GraphQL spec.
Example
use apollo_encoder::{Field, FragmentDefinition, Selection, SelectionSet, TypeCondition};
use indoc::indoc;
let selections = vec![Selection::Field(Field::new(String::from("myField")))];
let mut selection_set = SelectionSet::new();
selections
.into_iter()
.for_each(|s| selection_set.selection(s));
let mut fragment_def = FragmentDefinition::new(
String::from("myFragment"),
TypeCondition::new(String::from("User")),
selection_set,
);
assert_eq!(
fragment_def.to_string(),
indoc! {r#"
fragment myFragment on User {
myField
}
"#}
);
Implementations
sourceimpl FragmentDefinition
impl FragmentDefinition
sourcepub fn new(
name: String,
type_condition: TypeCondition,
selection_set: SelectionSet
) -> Self
pub fn new(
name: String,
type_condition: TypeCondition,
selection_set: SelectionSet
) -> Self
Create an instance of FragmentDeg
Trait Implementations
sourceimpl Debug for FragmentDefinition
impl Debug for FragmentDefinition
Auto Trait Implementations
impl RefUnwindSafe for FragmentDefinition
impl Send for FragmentDefinition
impl Sync for FragmentDefinition
impl Unpin for FragmentDefinition
impl UnwindSafe for FragmentDefinition
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